August 2010
Intermediate to advanced
288 pages
13h 21m
English
The Timer2 program has one potential problem: Because the Loop block checks the condition at the end of the loop, the timer will always wait at least one second. But what if the program determines that the delay should be zero or a negative number? The Timer2 program will still wait one second, which may not be the behavior you want.
To avoid pausing for one second when the delay is zero (or less), we need to check the loop condition at the start of the loop instead of at the end, as shown in the Timer3 program in Figure 10-28. In this program, the Compare block has been moved to the beginning of the loop, and the result is used to both exit the loop and control a Switch block. The Switch block makes sure that the ...