All exercises
4. Traffic light
Program a traffic-light sequence with three LEDs.
Task
- 1.Run the program and watch the colour sequence.
- 2.See how the show() function shortens repeated code.
- 3.Make the green light blink three times before it turns off.
Code
Tab inserts two spaces. To leave the editor press Esc, then Tab.
Virtual stand
Program not started
| Pin | Part | State |
|---|---|---|
| D9 | Red LED | off |
| D10 | Yellow LED | off |
| D11 | Green LED | off |
Serial monitor 9600
The program has not sent anything over Serial yet.