Go Down

Topic: static variables (Read 2 times) previous topic - next topic

Professor Chaos

Of course you could use a global variable as well.


...since the loop() routine will always be running, even if I go to other functions.

"always be running" might be a bit misleading you:
Sure you may call other functions from loop, and after returning from there, your code executes just the next line.
But loop() ends at the bottom (or with a return; statement), it is just (rather soon) restarted again, and all local non-static variables are created from fresh.

Go Up