Getting programming questions answered on the internet can be problematic. Programmers love to have opinions, stick to those ideas, and express them to you even when their opinion has nothing to do with your question(s).
Not only am I going to explain how to use flag variables in your code, I am going to encourage their use—which most programmers avoid.
However, this advice comes with two caveats.
- This information only applies to limited resource environments like an Arduino, LaunchPad or PIC.
- Use flag variables very carefully when you do use them.
The following flag variable usage examples are Arduino-centric but apply to any microcontroller platform, including the Energia project for TI Launchpads.