a programmable timer, version 3
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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access