Back to Parent

Exercise 3

Go back to the original program. Now add a second LED to the circuit.

Program the LED’s to alternate blinks i.e. when LED 1 turns on, LED 2 turns off, then when LED 2 turns on, LED 1 turns off.

In the beginning, I was about to use separate digitalWrite functions for the two LEDs. Then I think it is more efficient to just use one pair of digitalWrite for two LED pins, and swap after each loop.

I use a temporary variable to finish the swap at the end of the loop function (Bubble swap). The outcome is shown in the video.


Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0