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 ...