Skip to content
Emblem of the National Guard of the Republic of UzbekistanGUARDTECH
All exercises

4. Traffic light

Program a traffic-light sequence with three LEDs.

Task

  1. 1.Run the program and watch the colour sequence.
  2. 2.See how the show() function shortens repeated code.
  3. 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 states
PinPartState
D9Red LEDoff
D10Yellow LEDoff
D11Green LEDoff

Serial monitor 9600

The program has not sent anything over Serial yet.