Mission Critical: Intersection Alpha-Seven
The morning briefing crackles through the communication array as you review the schematic spread across your workstation. Intersection Alpha-Seven, Cogsworth City's busiest crossroads, has been operating on manual override for three days now. Traffic officers wave frantically at confused hover-cars while delivery drones circle overhead in holding patterns, their cargo bays full of essential supplies for the outer districts.
Chief Engineer Martinez taps the holographic display showing the intersection's layout. "The old quantum traffic controller fried its logic circuits during the solar flare last week. We need a replacement system, and we need it fast. The morning rush starts in six hours, and if we don't have those lights cycling properly, we'll have gridlock from the Industrial Quarter all the way to the University Sector."
You pull up the emergency protocols on your HERO Board. Three simple LED indicators: red for stop, yellow for caution, green for go. The logic seems straightforward, but the timing has to be perfect. Too short and vehicles won't have time to clear the intersection. Too long and the backup will stretch for kilometers. The city's entire transportation network depends on getting this rhythm exactly right.
As you connect the first wire to your breadboard, you can hear the distant hum of traffic outside the engineering bay. Thousands of citizens counting on you to restore order to the chaos. Time to build a traffic controller that will keep Cogsworth City moving.
What You'll Learn
When you finish this mission, you'll be able to:
- Control multiple LEDs in a precise sequence using your microcontroller
- Create realistic traffic light timing patterns that mirror real-world intersections
- Use the delay() function strategically to control program flow and timing
- Combine multiple outputs to create complex, coordinated behaviors
- Understand how automated systems manage critical infrastructure in cities
Understanding Traffic Control Systems
Every day, millions of people navigate intersections without thinking about the invisible conductor orchestrating the flow. Traffic lights operate on precisely timed sequences, each phase calculated to maximize throughput while maintaining safety. The system you're building mimics this real-world choreography.
Think of a traffic controller as a state machine. At any given moment, it exists in exactly one state: showing green, yellow, or red. But unlike a simple on-off switch, it transitions between these states automatically, following predetermined rules about duration and sequence. Green holds long enough for traffic to flow, yellow provides a brief warning, and red stops movement while cross-traffic gets its turn.
Your microcontroller excels at this type of sequential control. It can track time, remember which state comes next, and switch outputs with microsecond precision. By programming specific delay intervals between state changes, you create the rhythmic pulse that keeps urban transportation systems functioning. The same principles apply whether you're controlling a small town intersection or coordinating the complex light networks of a major metropolitan area.
Wiring Your Traffic Control System

- Connect the red LED's long leg (positive) to digital pin 8 on your HERO Board. This pin will control when vehicles must stop.
- Connect the yellow LED's long leg to digital pin 9. Yellow serves as the critical transition warning between stop and go.
- Connect the green LED's long leg to digital pin 10. This pin controls the go signal for traffic flow.
- Connect all three LED short legs (negative) to the ground rail on your breadboard using separate wires.
- Finally, connect the ground rail to any GND pin on your HERO Board to complete the circuit.
Each LED needs its own digital pin because the microcontroller must control them independently. The shared ground connection provides the return path for current, while the individual digital pins act as switches, turning each light on or off as needed.
Code Walkthrough
Time to build the brain of your traffic control system. We'll construct this program in logical chunks, each handling a specific aspect of traffic light operation.
Step 1: Define the Control Pins
int red = 8;
int yellow = 9;
int green = 10;