arduinoLoops


Syntax

  • for (declaration, condition, iteration) { }
  • while (condition) { }
  • do { } while (condition)

Remarks

General Remark If you intend to create a loop to wait for something to happen, you're probably on the wrong track here. Rather remember that all code after setup() is run from a method called loop(). So if you need to wait for something, it's easiest to not do anything (or only other independent stuff) and come back to check for the waiting condition next time.

do { } while(condition) will not evaluate the condition statement until after the first iteration. This is important to keep in mind if the condition statement has side effects.