Traffic light with flip-flops
Build it step by step
0 of 7 doneDraw the state diagram
Four states and the lamps for each.
Build the clock
555 and the timing parts.
Add the counter
Watch Q0 to Q3 light in turn.
Wire the reset
Q4 to reset.
Add the OR gates
Red and amber outputs.
Fit the lamps
LEDs with 330 Ω.
Change the speed
Swap the timing capacitor.
How do you build a traffic light with flip-flops?
A counter and gates step through red, red-amber, green and amber with no code, a hardware state machine. You need CD4017 Counter, NE555 Timer IC, 74HC32 quad OR gate, LED 5 mm red, LED 5 mm yellow, LED 5 mm green, Resistor 330 Ω × 3, Resistor 10 kΩ × 2, Electrolytic capacitor 10 µF, Electrolytic Capacitor 100 µF, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and Breadboard power supply module (MB102). It takes 7 steps and about 120 minutes.
- Level
- Intermediate
- Time
- About 120 min
- Parts
- 13
Parts list
- Integrated CircuitsBuyCD4017 Counter × 1
- Integrated CircuitsBuyNE555 Timer IC × 1
- Integrated CircuitsBuy
- SemiconductorsBuyLED 5 mm red × 1
- SemiconductorsBuyLED 5 mm yellow × 1
- SemiconductorsBuyLED 5 mm green × 1
- PassivesBuyResistor 330 Ω × 3
- PassivesBuyResistor 10 kΩ × 2
- PassivesBuy
- PassivesBuy
- PrototypingBuy
- PrototypingBuy
- PowerBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| 555 pins 8 and 4 | 5 V | Power and reset |
| 555 pin 1 | Ground | Ground |
| 555 pin 7 | 10 kΩ to 5 V, and 10 kΩ to pins 2 and 6 | Timing |
| 555 pins 2 and 6 | 100 µF to ground | Timing capacitor |
| 555 pin 3 | CD4017 pin 14 (clock) | Slow clock about every second |
| CD4017 pin 10 (Q4) | CD4017 pin 15 (reset) | Wraps after four states |
| CD4017 pin 3 (Q0) and pin 2 (Q1) | 74HC32 pins 1 and 2 | Red is state 0 or 1 |
| 74HC32 pin 3 | 330 Ω to red LED to ground | Red lamp |
| CD4017 pin 2 (Q1) and pin 7 (Q3) | 74HC32 pins 4 and 5 | Amber is state 1 or 3 |
| 74HC32 pin 6 | 330 Ω to yellow LED to ground | Amber lamp |
| CD4017 pin 4 (Q2) | 330 Ω to green LED to ground | Green is state 2 |
| Power pins | CD4017 pin 16 and 74HC32 pin 14 to 5 V, CD4017 pin 8 and 74HC32 pin 7 to ground, CD4017 pin 13 to ground | Chip supply |
No code needed
A state machine remembers where it is and moves to the next state on each clock; a ring counter such as the CD4017 is the simplest memory, with one output high at a time, so Q0 to Q3 are the four states of a UK-style traffic light: red, red and amber, green, amber. Red is lit in states 0 and 1, so an OR gate joins those two outputs; amber is lit in states 1 and 3 so another gate joins those; green is state 2 and needs no gate. When the counter reaches state 4, the Q4 output is wired back to reset, so it starts again at state 0. The 555 clock with 10 kΩ, 10 kΩ and 100 µF ticks about once every 2 seconds, so change the capacitor to 10 µF for a faster demo. Draw the state diagram and a truth table before building; they give the wiring. Use a 5 V supply module on the breadboard, check chip pin numbers carefully, and unused inputs on the OR gate must be tied to ground; if the lights misbehave, the first things to check are the reset wire and the supply.
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| State 0 | Red only |
| State 1 | Red and amber |
| State 2 | Green only |
| State 3 | Amber only, then back to red |
If it does not work
Stuck on one state
Check the clock output and the supply.
Never returns to red
Check Q4 to reset wire.
Wrong lamp
Check the OR gate inputs.
Too fast
Use a larger timing capacitor.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the traffic light with flip-flops?
CD4017 Counter, NE555 Timer IC, 74HC32 quad OR gate, LED 5 mm red, LED 5 mm yellow, LED 5 mm green, Resistor 330 Ω × 3, Resistor 10 kΩ × 2, Electrolytic capacitor 10 µF, Electrolytic Capacitor 100 µF, Breadboard 830 Tie Points, Jumper wires male to male (40 pcs, 20 cm) and Breadboard power supply module (MB102).
How long does the traffic light with flip-flops take to build?
About 120 minutes for a intermediate maker, in 7 steps.
How do I know the traffic light with flip-flops works?
State 0: Red only. State 1: Red and amber. State 2: Green only.
Stuck on one state: what should I check?
Check the clock output and the supply.
Never returns to red: what should I check?
Check Q4 to reset wire.
Wrong lamp: what should I check?
Check the OR gate inputs.
Too fast: what should I check?
Use a larger timing capacitor.
