Tactiverge BuildBUILD 005
Build a Traffic Management System
A busy crossroads, a queue of buses, a pedestrian pressing the button and an ambulance on its way. Can you design lights that keep everyone safe and still keep the traffic moving?
Live build-along: not scheduled yet. Everything here works on your own, any time.
Why it matters
Traffic lights are one of the most common safety-critical controllers in the world, and their timing shapes how long millions of people wait every day. They are a clear example of competing requirements: pedestrians, drivers, buses and emergency vehicles all want different things, and the controller can never trade away safety to give them it.
Your objective: Design the controller for a virtual crossroads as a state machine: choose the states and transitions, guarantee that conflicting directions are never green together, fit in pedestrian crossings, and let an emergency vehicle take priority safely.
- 1.
The states
At any moment the junction is in exactly one state, such as 'north–south green'. The controller's whole job is choosing the next one.
- 2.
The clearance
Amber and a short all-red gap give cars already in the junction time to leave before anyone else goes.
- 3.
The button
A pedestrian press is remembered until it is served, even if the person stops pressing.
- 4.
The siren
An emergency vehicle can ask for priority, but the lights still pass through amber and all-red to get there safely.
Watch (optional, short)
Hand-picked explainers from their creators. Each one has a reason to watch it. Skip them if you’d rather just build.
Introduces machines that run on states and transitions, the same idea a traffic-light controller uses.
8 min 51 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
Introduces AND, OR, NOT and XOR, the building blocks behind every digital decision a computer makes.
10 min 7 s · captions on YouTube · source
Nothing loads from YouTube until you press play.
The engineering you’ll use
State machines
A system described by its states, the events that move it between them, and what it outputs in each state. Traffic lights are a textbook example.
Safety interlocks
Some combinations must never happen. Write them as logic and check them in every state, not just the ones you expect.
conflict = NS_green AND EW_green (must always be 0)
Memory (latching)
The controller needs to remember that the button was pressed. A latch holds a 1 until the crossing is served and it is reset.
Cycle and green share
The cycle time C is one full round of all phases. The fraction of time a road is green sets how many cars it can pass.
C = Σ phase times, green share = g / C
Average wait
If cars arrive at random times and queues clear quickly, the chance of meeting red is r / C and the average wait for those who do is r / 2. A 90 s cycle with 60 s of red gives an average wait of 20 s.
average wait ≈ r² / (2C)
Capacity
Queued cars leave one every 2 s once a green has been on for 2 s, and none leave on amber. So a green of g seconds lets about (g − 2) / 2 cars through on each approach.
cars per hour ≈ ((g − 2) / 2) × 3600 / C
Priority by interrupt
An ambulance's siren request interrupts the normal timetable: the controller cuts the conflicting phase short after its minimum, still runs amber and all-red, then holds the ambulance's green until it is through.
Connects to: Super-loops and finite state machines · Logic gates and Boolean algebra · Sequential logic and memory · Decisions and loops · Interrupts and event-driven code · Real-time computing on robots · Optimisation and gradient descent · Constraints, budgets and trade-offs · Robot safety and ethics · Testing and debugging
Same machine. Five ways in.
Pick the level that feels like a stretch, not a wall. You can switch any time, and your work saves to your Workshop.
◇ Explorer · Read the junction
Judge six moments at a crossroads as safe or a conflict, then say what the lights must show next at three moments in the cycle.
You’ll make: Six correct safe / conflict judgements and three correct next states.
Checked instantly on our server
At the live build-along
60 minutes, building together
- Team challenge
- Teams of three get the same junction and the same rule: never two conflicting greens. Each team designs a state machine that serves pedestrians and lets an ambulance through, then walks the room through one tricky transition. No leaderboard: every team that gets there explains how.
- Your own design
- On your own: choose a cycle time that keeps the average wait on the busy road as low as you can while giving pedestrians a crossing every cycle. Write down what you traded.
- Questions
- Moderated questions in the live room. Questions are answered on screen without names, and chat stays off.
- Extension
- Two junctions sit close together on the same road. How could you time them so a car that gets one green usually gets the next? What information would the second junction need?
- You leave with
- A saved, audited state machine, a rush-hour timing plan that passes on safety, waits and ambulances, a calculated cycle and a written trade-off argument, stored in your Workshop and counted toward your Passport.
For educators & facilitators
A complete run of show, misconceptions, safety notes and a printable worksheet.
Open the facilitator guideSafety: Browser simulation and paper design only. Never stand in a road or junction to observe or count traffic, and never touch traffic signals, control cabinets or street equipment; observe only from a safe place with an adult. Any physical extension needs an adult's safety review and supervision before anyone starts.
Go further
- → Playground: digital logic
- → Atlas: state machines
- → Atlas: sequential logic and memory
- → Playground: engineering trade-offs
- → Try BUILD 007 (Design a Smart Greenhouse) for another environment that measures and responds.
- → Atlas: sequential logic and memory, for how a circuit remembers that the button was pressed.
- → Playground: digital logic. Build the conflict detector and check it in every row.
- → Try BUILD 008 (Create a Virtual Computer) to see state and memory become a processor.