Spending time getting up to speed programming Arduino. I promise questions will slow down shortly...
I'm working with a piece of demo code for learning purposes and I've learned that all statements in setup() run at initialization and then flow goes to the loop() section of code.
However: I've got a couple proceedures in setup() and wanted to know if, after the in-line statments are executed, will the proceedures be executed before execution drops to loop(), or will the proceedures only be executed when called from the loop section of code? I assume only when called.
And what are the considerations regarding placing proceedures loop() or setup() section of the program?
Is it just about from where the proceedure will be called?
What if it will be called from both setup() and loop()?
Here's some of the code-
void setup() { Serial.begin(9600);//For access to serial monitor channel pinMode(Out0,OUTPUT); Serial.print("Enter s or f on serial terminal "); Serial.println("to make wink fast or slow"); //Two lines used just for readability on //a web page that explains this program. }
void fastwink() //Do one quick on-off... this is called many times as //the function "loop" executes repeatedly, thus the //Arduino appears to have a "wink quickly" function, //even though the quick winking is a combination of //two ingredients { digitalWrite(Out0,HIGH); delay(80); digitalWrite(Out0,LOW); delay(80); }
void slowwink() //Similar to fastwink. See rem there. { digitalWrite(Out0,HIGH); delay(900); digitalWrite(Out0,LOW); delay(900); }
void loop() { int incomingByte=0;//create and initialize a local variable
//The "then" part of the following will --snip--