Traffic Signal / Stop Light Wiring with Arduino Controller

I always wanted an old traffic signal and finally got one recently.  However, it was very simply wired so that all the lights were fixed on.  What fun is that?  I also wanted to try out an Arduino controller and thought this would be a nice simple project to incorporate it into. 

This Instructable will show you how to wire up an old traffic signal with an Arduino controller to function like a real traffic light.  I used a pretty simple program and controls.  Given the power of the Arduino controller, there are a lot of ways you can customize this.
Remove these adsRemove these ads by Signing Up

Step 1: Stuff you will need

Obviously you will need an old traffic signal.  I got mine on Craigslist for $40.  It is one of the newer plastic cased ones, but it looks fine from a distance.  I would kind of like an old metal one, but I'll have to upgrade later I guess.

The brains of this thing are going to be an Arduino Uno connected to a relay module. 

Arduino Uno

SainSmart 4-Channel 5V Relay Module
(Note:  This relay is pretty loud.  I can hear it click from across the room.  If anyone has suggestions for something similar that is not as noisy, let me know.)

You will need a power supply (transformer, wall wart, AC/DC adapter) for the Arduino.  I used a 12V 750mA wall wart that I had from some other piece of electronics that had died.  Most 7V to 12 V transformers should work.  You can pick one up at Goodwill for about $2.  Stay away from Radio Shack, they wanted $20-$30 for wall warts!  I am sure someone who knows more about the Arduinos can chime in as to what kind of amperage range you should stay in.  Here's one from Amazon that should work fine:

You will also need some male to female jumpers to connect the Arduino to the relay module (note, I did not have these but wish I did):

Note:  If you do not want to mess with the Arduino, there are a couple ready to go traffic signal controllers available online.  I could have gone this route, but I was really wanting to try out the Arduino:

A lamp or appliance cord with ground wire

Other materials you will need will depend on the starting state of your traffic signal.  I used some 16 ga wire (for the internal line voltage wiring), solder, sheet metal screws (for securing the Arduino and relay module, and attaching ground wires to the frame), wire nuts (for connecting line voltage wires), epoxy (to secure transformer), heat shrink tubing (to insulate transformer connections).


You will need a USB B cable to connect the Arduino to your computer to program it.  If you have a USB printer you should already have one of these.

Wire cutters
Wire strippers
mini flat head screwdriver for relay connections

Other tools you will need will again depend on the initial state of your traffic signal.  I used the following:

Cordless drill (for drilling holes in the case)
Soldering Iron (for wire connections and heat shrink tubing)
Dremel tool with milling bit (cut off some the plastic in the case to make mounting the new components easier)
Eye and hearing protection if you are using power tools.


You will need the Arduino programming software to upload the code to the Arduino:
ArrowCraft made it!2 days ago

It's really an interesting prject, here's mine! ;)

fzumrk (author)  ArrowCraft2 days ago

Nice Job! Are you using an AC to USB adapter to power the arduino? That's not a bad idea.

Yeah, my arduino was a little broken and I coludn't use any normal power supply's anymore. Thanks for replying by the way, I appriciate it! :)

This was also my first arduino project so thanks for helping me out.

truwebs9 hours ago
anybody know how to wire with 3 momentery switches instead of arduino?
MaC MoHaK1 year ago
this is the pdf link ( containing circuit layout and the schematics thati have been working with. but the arduino ide came up with a range of errors in the code when i tried to upload it.
plz help me write/modify the code for the circuit mentioned in the pdf.
p.s. : i am a beginner and ur help will be greatly appreciated
The one I'm waiting for would allow a timed cycle where the green illuminates for Seconds(x), then the Amber/Yellow for Seconds(y) and finally the red illuminates for Seconds(z) - Maybe even flashes.
fzumrk (author)  charlessenf-gm1 year ago
You should be able to do that with this setup. If you look at the Arduino coding on step 4, you can change any of the values such as "delay(20000)" to get the timing you want. This tells it to hold whatever it is doing for 20,000 milliseconds or 20 seconds. You can move the code lines around to change the sequence too.
"20,000 milliseconds or 20 seconds."

Would 2 min 30 sec be possible as well?

Ideally, I'd like 2:30 Green; 29 sec amber (flashing with increasing rapidity of possible) and red -until reset - at the 3 min mark.

And, to build the entire thing in a package small enough to be easily portable (in a briefcase/purse), be battery-powered and fit conveniently upon a small table.

And, of course I know noting about Ardurno's !!
Hey charlessenf-gm! I may be a bit late, but maybe you'll see this anyway.
What you describe should be possible.

When it comes to timing and pattern of the lights, there are no real limits.
You can have it flash and hold just the amount of time you like.
You could even add some random seconds to make it more interesting or even activate switching to green with a button or photocell.

When it comes to building it small. You can't really have the traffic light in your briefcase, but if you take the actual light out of the equation (or use a model with LEDs) you could even make something that would fit in a big pocket.

I had some fun with a few single-light LED traffic light and the arduino-based digispark at my office. Using the same (but 8-channel) relay module.

The micro-controller is about the size of a stamp. The big parts are the 5V power supply and the 8-channel relay module. If you made one controling LEDs and running on a 9V battery, you could probably make it fit a small matchbox.

Just send me a message if you want to ask someting. Here, on the youtube-link or my mail:

/Weber - Traffic Light technician.
I just made pretty much the exact same project a few weeks ago.
I used 3 solid state relays from sparkfun.

I made the board for a friend, who's adding it to his traffic light. He's now in the middle of hooking it up with an infrared sensor that many outside lights use these days. That way it will stay off most of the time and will come on automatically when someone walks close to it.
fzumrk (author)  declanshanaghy1 year ago
Nice design and compact too.
Wapata1 year ago
Great !
I've to do something like that for a friend.
But I think I'll use LED lamp and Ampli-OP.
By the way, don't you plan to add potentiometers to change the time-settings "on the flow" ? Or a mic to use the traffic signal as a vu-meter ?
fzumrk (author)  Wapata1 year ago
Now you are getting way too fancy for me. I figure if I want to change up the timing I can always just re-flash the Arduino. Those are good ideas for mods though.
The one I'm waiting for would allow a timed cycle where the green illuminates for Seconds(x), then the Amber/Yellow for Seconds(y) and finally the red illuminates for Seconds(z) - Maybe even flashes.
Microbe1 year ago
Nice idea, one day I was driving along and some workers were replacing old stop lights with new LED ones. I jumped out of my car at the lights, asked if I could have one, threw it in the back and away I went. Hadn't thought of using my arduino for something like this.
fzumrk (author)  Microbe1 year ago
Free stuff is the best.
RMDan1 year ago
Nice Project. I was thinking of doing something like this for my future office space. Instead of having it cycle, I would have a control unit to change the lights programmed on my computer. That way if I don't want to be disturbed the light is red, yellow is proceed with caution, and green is welcome.
fzumrk (author)  RMDan1 year ago
Good idea!
im_sparky1 year ago
Nice work!
You can eliminate the relay noise by using solid state relays.

fzumrk (author)  im_sparky1 year ago
Sweet. I think maybe I will swap that out and use the current one for another project. The clicking is pretty annoying.
jneveln1 year ago
Nice project. I've had a traffic light for years (picked it up at a DOT auction), and got an Arduino and a relay controller (EFX-TEK RC-4 relay board to do the same thing. I'm kinda stuck on how to mount everything since my light is metal and I want to make sure I don't zap myself with 120V.

I'd like to add a switch to go between some different modes, like blink, all on, random, blink in time to music, and maybe add a distance sensor to tell a car when to stop.
fzumrk (author)  jneveln1 year ago
As long as you mount everything so nothing is shorting against the case, and you ground the case, you should be fine. Look at how your PC case is put together for an example.

Alternatively or additionally, if there is enough room in the case, you could put plastic junction boxes inside it to house the electronics and wire connections.
Where'd you get the stopllight?
fzumrk (author)  Adambowker981 year ago You can find anything there with some patience. The person I bought it from originally bought it at a municipal auction.
skinzy fzumrk1 year ago
Great project. I have found traffic lights on ebay too.

I still need to post my project, but I tapped into a "Park-Zone parking aid" with some relays and am using that to control a (retired chicago) traffic light (purchased on ebay) in my garage.

Little cooler than a tennis ball hanging from the garage ceiling ;-)

fzumrk (author)  skinzy1 year ago
Someone else asked me how to incorporate a range finder for this purpose. I would recommend checking out this Instructable by RuiSantos:

It looks like he has a pretty good design for one which could be used as a starting point. A relay module could be inserted into his design instead of the LEDs to control the stop light.

You guys are making me want to incorporate this into mine now!