Arduino Traffic Light

[Rockwell] sent us an update on his traffic light hacking. Dedicated readers will remember seeing this legally attained traffic signal controlled through a parallel port from back in 2005. The new update swaps the old port for USB and adds several autonomous functions which are demonstrated in the clip after the break. The update includes a nice UI and some notifications for things like email, IMs, Reddit posts, etc.

He’s given control of the hardware over to an Arduino. Instead of building the board into the project he’s included just the parts he needs; an AVR running the Arduino bootloader, a crystal and filtering caps, and an Arduino serial to USB module for connectivity. The AC load switching is handled by three relays. The relays he links to are 12VCD rated coils. We think this should have pointed to 5VDC coils as that’s the voltage that the logic circuit are running at. Be careful with switching these AC loads, this traffic light isn’t a toy.

[youtube=http://www.youtube.com/watch?v=AWy8_jEEAMw]

28 thoughts on “Arduino Traffic Light

  1. That circuit is terrible. Do not build that circuit, unless your microcontroller has offended you in some way.

    The guy decided to drive each coil DIRECTLY with the combined output of two logic lines. A the very, very minimum put a diode in there to absorb the kickback.

  2. @Joel
    I couldn’t believe what you were saying so much, I had to see for myself!
    I know micro-controllers are robust things but sticking in the reverse-diodes to handle the back-emf is just simply polite. :o)

    I do like the trick of using two drivers for a bit more current although, again, is a transistor that hard to design in and would using them as sinks rather than sources not be better? (I don’t know the exact internals of the *unio but a lot of uC can sink more current due to the design of the output buffer)

  3. I’ve got an old school Marbelite 8″ head with 2 pedestrian Don’t/Walk units in my house purchased from a great guy running Twin Green signals in upstate NY. Getting a real cast stand makes all the difference in display.

    A simple avr runs the show. I use opto-isolated triacs, which I think is easier and cleaner than relays.

    Be sure to check out the Traffic Signal Museum…

    http://www.trafficsignalmuseum.com/

  4. btw, using ‘normal’ light bulbs in those things is bright as hell in the house… I use 7W sign bulbs for red/green and a 3W nightlight bulb for yellow (which was too bright even at 7W).

  5. @Mike “this traffic light isn’t a toy.”
    it is, and badly designed one

    ps. Imagine how great HaD would be if only Mike stop fapping each time after hearing word “Arduino”, what a pervert

  6. Okay so he heeds some diodes in the circuit.

    Overall I like the project.
    Sure it needs tweaks, but what project DOESN’T?

    This isn’t “finishedproduct a day”

    It’s possible to be constructive and civil in your discourse.

  7. @Joel et al.

    Poor poor uC….Any one attempting this should heed those words…Not only should you use an opto-coupler to isolate your uC but you should also drive your relays at their rated voltage. I’m surprised it even worked at 5V. (Running at lower than rated could be a failure risk when you approach the rated current/voltage of the relays contact…if your voltage can’t keep the contact closed it could flutter causing all sorts of safety issues.)

    Just so you don’t have to look it up…the ATMega168 I/O pins have a max of 40mA, and the total for the chip shouldn’t exceed 200mA…

  8. @Pedro – “Agent420, if you’re using triacs ratehr than relays, can’t you do some fancy dimming of the bulbs with your uC?”

    Indeed I can, though using sufficient pwm to dim conventional wattage bulbs resulted in power noise in nearby audio equipment. It was easier to switch bulbs than add the required noise supression circuitry.

    I understand the original poster’s desire for relay sound – in fact I did add a large relay for sound fx, but it can be switched off for quiet night operation.

  9. I don’t know what to say. I think criticism should be helpful to the community and respectful of the authors efforts too.

    To that end I will say reverse diodes are a must but, I am shocked to read the author has not had problems so far.

    Opto isolation? I suppose since it can be connected to a computer the failure could be costly so I vote yes. Otherwise I wouldn’t bother.

    An arduino is a good choice here as the HW already takes care of the USB serial connection.

  10. Josh, it’s not necessary to use optocouplers with a relay. Just protect your outputs from the inductive kickback voltage (here the atmega internal protection circuitry does this job, but it’s really not meant to).
    While we’re at it, there are other security issues : using very thin wires to carry AC, splices covered with a piece of tape that is already starting to peel off … But then again it’s a “hack”. I’ve done this numerous times (with 240V) without problems. (The only time I was ever electrocuted was with a commercial product :-) )
    A funny thing is the USB cord, he made a knot but he left too little slack so if you pull on it it will unplug anyway ^^

  11. Wow, look at the firestorm I started. Someone on here sent me a long and very detailed e-mail explaining why I should put some reverse-biased diodes in there when driving the relays. It makes sense, and I think I am forced to do this. I’ll look through all the other responses here for other options, as well.

    I’ll take down the schematics in the meantime.

    @Agent420: Yeah, the light originally came with special 100W bulbs designed for traffic lights. I replaced them with 40W bulbs. The old version had a totally separate plug for AC, so I actually had a dimmer switch on that one, but I can’t do that here because there is a DC converter inside.

  12. @Rockwell

    Check out Home Depot or Lowes, they carry standard base low wattage ‘sign bulbs’, these usually have more resilient filaments that last longer when the bulbs are used in a frequent on/off environment. The ones in my traffic head have been running for several years.

    http://www.lowes.com/lowes/lkn?action=productDetail&productId=130780-75774-017801995169&lpage=none&cm_mmc=search_gps-_-gps-_-gps-_-Feit%20Electric%2011-Watt%20S14%20Sign%20Bulb%20130-Volt

    As for the diodes, you should use them any time an inductive (coil) load is switched from a solid state device like ic’s or transistors – when the power is turned off, the coil creates a large spike of opposite polarity, exactly the way a spark coil works in a car. Although microcontrollers are cheap these days, you still might as well take some preventative steps to keep it alive; this kind of damage can ‘build up’ over time so failure is not always immediate.

    As for the ‘firestorm’, don’t sweat it – you were nice enough to post your work so ignore the harsh criticism.

  13. SSRs would also solve the problem. You get your opto isolation, and they can be triggered by the logic voltage easily. A smallish 2-3A capacity epoxy cased is not more than the mechanical relays as far as cost. Plus no clakity-clakity.

  14. There are some relays out there that are rated for less than 40ma@5V to switch line voltage.

    For example,
    http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=Z2774-ND

    They just can’t switch very fast (no more than 1hz under full load). I tried to use them for a Christmas light controller, and I quickly burned out two of them trying to find the max frequency they could switch under load. I am redesigning it to be solid stare right now.

  15. In the late 80s I rigged a traffic light with three cascaded one-shots feeding three solid-state relays to switch the bulbs.

    The traffic light parted ways with its pole base during a violent storm and was recovered from parts unknown and eventually gifted to me.

    It executes a realistic and repeating 1 minute green-10 second yellow, 1 minute red pattern. The relays also provide the authentic CLICK sound as the old-school ‘large control box at the base’ traffic lights did.

    The solid state relays were new and vogue at the time. The one-shots were the simplest way to achieve a repeating sequence at the time.

    No, it isn’t programmable unless you change out the RC timing components. But it still runs today as designed, and I don’t think I ever considered it a hack.

  16. Reverse diodes are such a simple, sweet solution to many crashes. I am of course partial to them from extensive keyboard repair on synths lol. I like the opto coupler too, reminds me of my midi stuff (ground loop be gone!) and another simple solution to an all too common problem :)
    Gonna have to go here though and give my two cents as to the arduino effect here. I mean I think the radio shack kits with the springs have schematics for logic timers and so forth. It might not be so newsworthy as such. Maybe I’m missing something here, though.

    BTW this godforsaken backlit keyboard from the thrift store is the absolute worst thing I have ever used. The keys are actually smaller than a laptops somehow. I may CL it but any ideas what to do (fun) with it that doesn’t involve the word “sideways” in it?

  17. I had fun with some reverse diodes. We were finishing a drink bot revision (I will get something posted eventually I just want more features added) we didn’t have any conventional diodes around but we did have LEDs. It is fun to watch a solenoid turn off because there is a nice flash of light. I know it is horrible on the LEDs but they are surviving (going from ~12V reverse to a forward peak of 150mA). When they die we will replace with real diodes.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.