Make an interactive traffic light system for toy cars!
BUILD TIME: 2 Hours
DIFFICULTY RATING: BEGINNER
With an exceptionally positive response to our Issue #13 Kid’s Basics project using Sensors and Servos, we’ve come up with another project for you to enjoy. A functioning set of traffic lights!
You can use it on just about any scaled car or train tracks, plus we have provided a track for you too. You can print the black and white versions and colour them yourself, or use the full-colour versions.
This project consists of two projects based around the same concept. The first is to build the traffic light module itself, then we connect it up into a working system in the second build.
We’re assuming very little (or zero) electronics knowledge, and so will try to walk through everything carefully, in order to ensure your success. Basic computer skills are assumed (as is access to a computer, with internet connection, to use the software). If you have trouble following any of the software installation steps, then you may like to seek further assistance from a family member or friend. There are a few too many potential challenges for us to detail every possibility here.
The projects provided here are all progressive, directly following on from the preceding build. You can skip ahead, but this article is written expecting sequential build construction, so you may miss out on some explanations and tips along the way, if you do.
|Craft materials & TOOLS Required:|
|1 × Computer Running Windows, Mac, or Linux with Connected A4 Printer|
|1 × Bull Nose Pliers|
|1 × Pair of Scissors / Artwork Knife|
|1 × Glue Stick|
|6 × A4 Sheets of Cardboard (Thick)|
|1 × Pack Blu-Tack / Tape etc.|
|Markers, Pencils or Crayons (if using outlined versions for colouring)|
Craft materials & TOOLS Required:
|Electronics PARTS Required:||Jaycar||Altronics||Core Electronics|
|1 × Arduino UNO or Equivalent||XC4410||Z6240||018-UNO-R3|
|2 × SG90 Servo Motors||YM2758||Z6392||SER0043|
|1 × Mixed Jumper Wires||WC6027||P1017||PRT-08866|
|1 × Small Prototyping Breadboard||PB8820||P1002||CE05102|
Electronics PARTS Required:
|Traffic Light Electronics (OPTION 1):||Jaycar||Altronics||Core Electronics|
|2 × Traffic Light Modules||XC3720||-||-|
Traffic Light Electronics (OPTION 1):
|Traffic Light Electronics (OPTION 2):||Jaycar||Altronics||Core Electronics|
|2 × 10mm Red LEDs||ZD0200||Z0900||COM-10632|
|2 × 10mm Yellow LEDs||ZD0210||Z0902||COM-10634|
|2 × 10mm Green LEDs||ZD0205||Z0901||COM-10633|
|2 × 330Ω Resistors*||RR0560||R7546||PRT-14490|
Traffic Light Electronics (OPTION 2):
You will also need a USB cable compatible with your Arduino UNO, which may or may not be supplied with the Arduino UNO itself. Power for these projects is provided from your computer. No additional power is required. *Quantity shown, may only be available in packs.
You will need to have an Arduino UNO (or similar), and the Arduino IDE installed on your computer. You can download it for free, from www.arduino.cc/en/Main/Software. Follow the prompts to install it. This is where we will load code, and compile it onto the Arduino.
With your Arduino connected to your computer via USB, go to Tools › Board and ensure Arduino / Genuino UNO is selected, or the appropriate board for what you are using.
Then also select Tools › Port and click on the one that shows USB. The precise wording will depend on your operating system.
In order to load code onto your Arduino, open the Arduino IDE once installed. Go to File › Open and select the file noted in the article (Each file is within a folder of the same name).
COLOURING & PREPARATION
You will notice that there are printable parts. These can be printed on any home printer on an A4 sheet. While these are not critically essential, it helps make the builds more fun than simply something moving without any context.
We have provided coloured, and non-coloured illustrations for the projects. This is to allow you to either add-on the fun of colouring the interactive scenes, or simply get on with the interactive portion. The choice is yours.
For each build, you’ll need to bond the backing card and interactive elements to some cardboard. This will help provide structural integrity to the overall project. The paper itself is too flexible and will simply bend. The cardboard should be thick enough to hold itself up, but not so thick you cannot easily cut it with scissors.
The Fundamental Build:
Traffic Light Module
If you have purchased the traffic light modules listed in the parts list, then your task is somewhat easier. However if you weren’t able to purchase the light modules, or would simply like to build your own, then follow these steps.
If you have a soldering iron and solder, and have soldered before, then this is the best method to ensure the connections work as intended. However we’ll show you how to do it without solder too. Soldering is more robust, but not essential.
Glue the traffic lights holder prints to your backing cardboard.
Carefully cut out the traffic light housing as shown in the photos.
Cut out the holes for each of the LEDs to poke through, and remove any excess paper to create as close to a circle shape as possible.
If you are using a traffic light module, attach four male to female jumper wires to the pins (match colours if you can, but not essential). Push the module carefully into the holes as shown. Then skip to step 8 to help identify wires later.
If you are not using pre-built traffic light modules, we will assemble our own now. Be careful to orient the LEDs with the short leg together - these are the legs which need to be twisted together. This is important, as the LEDs will not work if oriented incorrectly. A little glue or Blu-Tack may assist holding things in place if required.
Holding the LEDs as shown, twist the wires from the LEDs together as shown. It’s important to twist carefully, yet firmly to ensure a quality electrical connection (but leave enough gap to fit in the cardboard as required - check-fit as you go if needed).
Take a resistor and twist it onto the end of the combined wire. Connect a female to male jumper wire to the end of the resistor.
Take a female to male jumper wire and connect it to each of the remaining LED legs. You can then poke the LEDs through the cardboard holder.
Cut-out the "wire-markers” piece from the paper and make four small holes. Poke the wire from the resistor/ground through the “GND” hole, and the other three wires through the “R”, “Y”, “G” holes as appropriate. This will help you ensure wiring is correct later.
Tape, glue, or Blu-Tack the wires in place to help avoid them pulling out (tape or Blu-Tack is best if you want to re-use the hardware later).
To test each LED is working, insert the “GND” wire to GND on the Arduino. Then one at a time, insert the "R", "Y", "G" wires into the “5V” socket in the Arduino. You should see each of the LEDs illuminate as you do. If you don’t, check the connections for any that do not (note the Arduino must be powered up when you do this).
If you're including the boom gate, poke a small hole in the marked position and trim away any excess paper.
Poke the gear on the servo motor through the hole, then secure the servo motor in place using tape or Blu-Tack.
Push the servo horn onto the servo motor gear while supporting the servo motor from the back. Push firmly.
Fold and tape up the enclosure to enclose the module and form a complete traffic light.
Repeat for the second (and subsequent) traffic light modules also.
Automatic Traffic Lights
This build produces a working set of traffic lights, automatically switching between two directions of traffic. There is also an optional boom gate.
You will need two traffic light modules, as well as the printed road (optional), and your Arduino to power everything. Then it's just a matter of wiring them into the Arduino appropriately.
There are a number of connections to be made, however they're fairly straightforward and you should be able to follow the diagrams without too much trouble.
Be sure to double-check that your lights are working before proceeding. It could save some hair-pulling if things don't work later in the build.
Print out and trim the "road" if you want to use it. You can print and arrange as many pieces as you like.
Use male to female jumper wires to extend the wires on your modules. This will be necessary to ensure everything can reach the Arduino. The wire guide should be moved down too.
Arrange your two traffic light modules on the road. They are designed to be placed on intersecting streets.
In an effort to keep the wiring somewhat tidy, tape the wires to the side of the light.
Use a paddlepop stick to create a "wire support" from one side to the other - this will help us get all the wires across to the Arduino from the furthest point of the intersection. You can optionally run the wires underneath the track, but we found this to be more reliable.
Secure the wires with tape so they can't move too far.
Complete the wiring as per the diagram below. Take your time to carefully connect each wire as shown. It may look complicated, but with care it's fairly straight forward.
We have provided traffic_lights.ino in the digital resources. Connect your Arduino and load the code onto your UNO. You should see things spring to life, and the lights start automatically running after a few seconds.
Now is a great time to attach the boom gates if you want to use them, and have added the servo motors to your build. You simply need to wait for the "red light" and attach the boom gate.
This build is a little more complicated than our first build, because there's actual electronics wiring to do, and more connections required to make everything work.
The wiring may be where this project can fall down, so we will also publish a video showing the wiring connections step-by-step for this build, to guide you through the process too. Check out the link below for the video of this and other material. There are also two ways to expand this system:
MORE LIGHTS - You can add lights so you have lights on both sides of the intersection. Simply build another two traffic light units, and connect them to the same points in the breadboard. We'll elaborate on this a little in the video also.
MORE INTERSECTIONS - Simply repeat this entire process as many times as you like to bring illuminated intersections to your miniature sets and tracks, for hours of endless fun!