arduino Loops

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


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


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.

Got any arduino Question?