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
Project illustration
A visual reference for this build. Use the parts, wiring, and instruction sections below for exact assembly details.
Recommended for
- Middle School
- High School
- Adult Beginners
- Homeschool
Skills
What You'll 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
Required Parts
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
Wiring
Circuit Diagram
Red, yellow, and green LED anodes connect through 220 ohm resistors to GP15, GP14, and GP13. All cathodes share GND.
Circuit overview
Three-output traffic light circuit. Follow the written connection notes and numbered build steps for exact wiring.
Build
Step-by-Step Instructions
Work through each stage in order and disconnect power before changing the wiring.
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.
Programming
Project Code
Upload traffic-light.py after completing the circuit.
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
Troubleshooting
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
FAQ
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.
Go deeper
Related Tutorials and Resources
Project complete
Ready for Servo Motor Control?
Sweep a small hobby servo through precise angles using PWM from a Raspberry Pi Pico.
Reuse your kit
More projects you can build with this kit
Keep using the SunFounder Raspberry Pi Pico Ultimate Starter Kit instead of starting with a new parts list.
Blink an LED
Wire and program an LED to blink at a steady interval with a Raspberry Pi Pico.
View projectLED Night Light
Build an automatic LED night light that turns on when the room gets dark.
View projectPassword Lock
Build a keypad-controlled lock that moves a servo when the correct code is entered.
View projectServo Motor Control
Sweep a small hobby servo through precise angles using PWM from a Raspberry Pi Pico.
View projectUltrasonic Distance Sensor
Measure distance with an HC-SR04 sensor and display live readings in centimeters.
View project