© Bob Dukish 2018
Bob DukishCoding the Arduinohttps://doi.org/10.1007/978-1-4842-3510-2_4

4. More Loops, and More Elegant Methods to Flash an LED

Bob Dukish1 
(1)
Canfield, Ohio, USA
 

Timer Loops

The delay command is useful in most circumstances and it is easy to understand, but a for loop works very well as a timer whenever we want to repeatedly run a command a specific number of times, or when we wish to accomplish an additional task, or easily break out of the delay. Using a timer for loop should fix our delay bug from Chapter 3. In our program, our only additional task is to allow the possibility to break out of a delay, and leave the delay without returning there after an ISR or subroutine is activated. Note that both ISRs and subroutines are small ...

Get Coding the Arduino: Building Fun Programs, Games, and Electronic Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.