EngineeringMaker Lab

Build guide

Featured project

Traffic Light

Expand a single blinking LED into a clear state sequence. This project introduces multiple outputs, reusable functions, readable timing constants, and systematic breadboard wiring.

Last updated

Build Time
35-50 minutes
Estimated Cost
$10-$18
Skill Level
Easy
Raspberry Pi PicoRaspberry Pi PicoLEDsGPIOSequencing

Project overview

What You Will Build

1. Build three LED branches

Place the LEDs in traffic-light order. Connect each anode to its assigned GPIO through a separate 220 ohm resistor and connect all cathodes to ground.

2. Test one color at a time

Before running the full sequence, briefly set each GPIO high in Thonny’s shell. Correct any color or polarity mistakes now.

3. Run the sequence

Upload the program and confirm the order is red, green, then yellow. The show function guarantees only one light is active.

4. Tune the timing

Change the duration values to model a faster tabletop demonstration or a more realistic intersection cycle.

Skills

What You Will Learn

  • Control several GPIO outputs independently
  • Organize repeated behavior in a function
  • Build and verify repeated LED circuits
  • Translate a real sequence into program states

Preparation

Parts Used

Gather these components before starting the build.

  • Qty: 1Raspberry Pi PicoMicroPython installed
  • Qty: 1Solderless breadboardHalf-size or larger
  • Qty: 3LEDsOne red
  • Qty: 3220 ohm resistorsOne per LED
  • Qty: 4Jumper wiresMale-to-male

Verified resource

Complete Official Build Guide

Traffic Light

Already have the recommended equipment? The verified SunFounder lesson provides the exact wiring, schematic, code, and step-by-step build instructions.

The verified Thales MicroPython lesson provides the exact traffic-light wiring, schematic, code, and step-by-step build instructions.

Original preparation

Original Code and Preparation Notes

This independently written example summarizes the programming concept used by the project. Compare wiring and pin choices with the verified official guide, when available, before running traffic-light.py.

traffic-light.pypython
from machine import Pin
from time import sleep

red = Pin(15, Pin.OUT)
yellow = Pin(14, Pin.OUT)
green = Pin(13, Pin.OUT)

def show(active, seconds):
    for light in (red, yellow, green):
        light.value(light is active)
    sleep(seconds)

while True:
    show(red, 4)
    show(green, 4)
    show(yellow, 1)

Problem solving

Common Beginner Mistakes

One color does not light

Test that LED alone

More than one LED stays on

Confirm each anode has its own GPIO row and that the function sets every non-active output low.

The sequence order is wrong

Match the physical LED colors to GP15

Common questions

Frequently Asked Questions

Can I add a pedestrian button?

Yes. Add a pushbutton input and check it between sequence states.

Why use a function?

The function keeps repeated output and delay logic in one place

Can all LEDs share one resistor?

No. Each LED should have its own current-limiting resistor.

Project complete

Ready for Ultrasonic Distance Sensor?

Measure distance with an HC-SR04 sensor and display live readings in centimeters.