Skip to content
07micro:bit · MakeCode 30 minutes

Traffic lights

Three LEDs on P0, P1 and P2 in a timed sequence.

Traffic lights project
Illustration of the finished idea. Build from the diagram and connection table, not the photo.

Lesson goal: Run red 3 s → green 3 s → yellow 1 s using a function that turns all lights off before lighting one.

Open MakeCode

Section 1

Understand

  • functions
  • several outputs
  • sequence
  • common ground
  • 1Red on P0, yellow on P1, green on P2, each with its own resistor.
  • 2Turn all off, then light the chosen colour.
  • 3Red 3 s, green 3 s, yellow 1 s.

Safety first

  • Unplug the USB cable before you add, move or remove any wire. Plug back in only after an adult or you have re-checked every connection against the table.
  • micro:bit pins are 3 V logic. Never connect 5 V, a battery pack or anything from a 5 V supply to any ring, port or the 3V ring.