Monday, February 16, 2015

2: How the Arduino "Sketch" Works (maybe)

For C or C++ programmers the hidden code behind the sketch probably works (or can be visualized) like this:

void main() {
setup();

while(1) {
    loop();
}

Of course this doesn't explain other stuff you can add -- like this:

//optional #include statements
//optional #define statements
//optional variable declarations

setup() {
//whatever
}

loop() {
//main code -- an exit() just reexecutes loop()
}

//optional user-written functions


No comments:

Post a Comment