Consider the example in the Digital Output tutorial with the blinking LED. The code for this example was written in a procedural way:
- Set the output pin to the current state of the LED
- Flip the current state of the LED
- Wait for 1 second
- Goto step 1
This code is very straightforward for simple models.
How would you write a program to blink two LEDs at different rates, e.g. with periods 1000ms and 1100ms?
- What if you had three LEDs with periods of 1000ms, 1100ms, and 1110ms? Would your algorithm still work
- What if you had an unknown number of LEDs, each with an unknown period? Would your algorithm still work?