This Arduino-based traffic light controller will teach you about timing sequences and works as an actual stop light!
This Arduino-based traffic light controller will teach you some things about timing sequences on Arduino and works as an actual stoplight! The lighting sequence performed by the Arduino mimics a four-way intersection. This traffic light controller can also help children learn traffic signal patterns so they can learn to cross intersections.
Arduino Traffic Light Schematic Diagram
Why?Originally, this was a simple LED project for people new to Arduino. We didn't think it would be all that helpful in the United States, but somebody in a small village in Vietnam actually recreated the project with bigger LEDs to make a real traffic light! It goes to show that you never know who will find uses for electronics projects that you may not have thought to be very useful, which is why sharing is an important part of making! If you have an electronics project that you haven't shared yet, feel free to share it on Maker Pro!
This project is also a good introduction to LED projects with the Arduino, like the ones below!
Arduino LED Projects
How to Build an Arduino LED Matrix in 3 Simple Steps
Bluetooth Basics: How to Control an LED Using a SmartPhone and Arduino
How to Make a POV Display Using LEDs and Arduino
Create a Christmas Light Show with Arduino
How Does the Traffic Light Controller Work?It's really a simple concept and the table below helps to explain it. The code uses For loops and delay statements in order to implement the on-time for each of the LEDs.
The two streets in our example are Busy Bunny Lane and Lazy Tortoise Avenue. They each have different traffic volumes, so one has a longer green light (and a shorter red light).
Busy Bunny Lane is pretty . . . busy. The green light for Busy Bunny Lane stays on for 12 seconds. Lazy Tortoise Avenue has much less traffic, so our hypothetical city has declared that it needs a green light that stays on for only one-third of the time that Busy Bunny's green light stays on. So Lazy Tortoise Avenue gets a 4-second green light. Fair is fair.
As Busy Bunny Lane switches from green to yellow to red, Lazy Tortoise Avenue briefly maintains its red light in case there are stragglers who try to make a last-minute dash through the intersection. Don't forget about this red-light-overlap interval if you ever design the traffic light system for your town's newest intersection. When the coast is clear, Lazy Tortoise Avenue gets the green light it has been patiently waiting for.
When Lazy Tortoise Avenue reaches its red light stage, there is another period of red-light-overlap, and then the loop restarts! This is a pretty basic and antiquated traffic light. Modern traffic lights today are "smart"—they can detect vehicles, adjust their timing, and even make interruptions for crosswalks. There is always room for improvement!
Arduino Traffic Light Controller Test Code
We'd love to see readers take this project and modify it to make it their own. Maybe turn this boring intersection into a "smart" one by adding a crosswalk interruption button! You can even change the light patterns based on the time of day! Take this knowledge and run with it, and remember to share your creations!