Introduction
Traffic lights are an important feature of modern road networks. They are found at crossroads,
pedestrian crossings and other intersections where traffic from different directions needs to be controlled.
Most common traffic lights have three lights arranged vertically: Red at the top, amber (yellow) in the middle and green at the bottom.
Red indicates traffic facing the light to stop and the green light indicates that traffic should proceed. What does the amber (yellow) light mean?
Traffic Light Technology
Most current traffic lights use a standard incandescent light bulb and a colored filter and lens. In the last decade, however, new traffic lights
use light-emitting diodes (LEDs). Each light consists of an array of many small LEDs which when viewed from a distance appear as a single light.
What other advantages are there of using LEDs in traffic lights? The project we will create here will use LEDs as the lights.
The Project
The Brainy-USB board has 3 digital outputs each capable of powering a LED. Design and build a small traffic light model out of cardboard.
One idea is use the cardboard toothpaste box, turn it inside out and paint it black, and then make holes for three LEDs: one red, yellow and green.
Connecting the LEDs to the Brainy-USB
Carefully wire the 3 LEDs to the 3 output connections on the Brainy-USB, ensuring that you have the connections the right way around.
Check with your teacher whether the LEDs you are using require a resistor to be
placed in series with each LED, and confirm the correct resistance required before connecting the LED!
Programming the Traffic Lights
Take a moment or two to write down the traffic light sequence for your traffic lights. Also consider what the length of delay should be between each step.
If necessary, take a stopwatch and find a local set of traffic lights and measure the pause and confirm that you have the right sequence.
Connect your Brainy-USB to the computer (click here
for help connecting) and check that the outputs work by clicking on the icons on the monitor bar along the bottom of the screen.
Then build up your program by dragging flowchart symbols on to the page. Begin with a Start symbol, next use an Output symbol to set the initial state of the lights.
Follow this with a Delay symbol to pause between each step in the sequence. Then continue adding Output and Delay symbols until the sequence has completed.
For the sequence to loop for ever, use the line tool to connect the last symbol back to the first symbol of the flowchart.
As you are building up your program, run each bit and test it as you go. Then when you're ready, download the program to the FlowIC microcontroller
on the Brainy-USB, disconnect from the computer and run your traffic light sequence remotely.
Extension: Use a sensor to detect traffic
Make your traffic lights smarter by connecting a magnetic read switch to the input. Then modify your flowchart to keep the light at red until a vehicle approaches.
Extension: Pedestrian Crossing
Alternatively, connect a push switch to the input on the Brainy-USB board. Then adjust your program so the push switch is the button pushed by a pedestrian
waiting to cross the road. Note that because the Brainy-USB board is limited to three outputs we cannot add lights for the pedestrian stand (stop) and walk signals.
Are the traffic light sequences for a crossroads and a pedestrian crossing different?