I'm going to present the circuit and programs for this chapter in the form of a practical exercise. Let's pretend for a moment that we have been asked to design and build a gizmo that has the following requirements:
- It has two LEDs that blink.
- A potentiometer is used to adjust the rate that the LED(s) blink.
- When the program starts, both LEDs will blink at the same rate determined by the position of the potentiometer.
- A blinking rate of 0 seconds means an LED is off, while the maximum blinking rate of 5 seconds means an LED is on for 5 seconds, then off for 5 seconds, before repeating the cycle.
- A push-button is used to select which LED changes its blinking rate when the potentiometer is adjusted.
- When the push-button is pressed and held for 0.5 seconds, all LEDs synchronize to the same rate, determined by the potentiometer's position.
- Ideally, the program code should easily scale to support more LEDs with minimal coding effort...