I can obviously call functions but is there a way to call my setup function? Reason: supose in my setup I've populated peramiters which will be used in my loop. If I wish to change them (and there are many of them) without restarting my system, is there a way that I can go back to setup? This is what I've tried and it did not work.
void loop()
{
if (Serial.available() > 0)
{
int incomingByte = Serial.read();
delay(2);
if (incomingByte == 86) //shift V should satisfy the if statement and call the function
{
setup();
}
}
//other stuff in the loop
}
Any help would be great. I can live without this but it sure would make things easier if I could figure it out. :~
Thanks
You can also call loop(), even recursively if you want, why not
Because recursive functions are supposed to have end end, so you don't run out of stack space. Your example may run 1023 levels deep. I doubt that there is sufficient stack space for that.
I guess one could make the case that needing to call the setup() function in your main loop() function means you are doing stuff in the setup function that should rather be done is a user written function that can be called anywhere in the sketch required. Kind of by definition stuff in the setup function should be stuff that only requires one time initialization or action. Having to call setup() within loop() just sounds like unorganized logic to me, but then maybe I'm just use to reading too many 'normal' sketches.