The Traffic Light Hack, Mark II

by Rockwell Schrock

Introduction

The Traffic Light Hack is a simple interface for controlling lights inside a traffic light enclosure. No, not a real light out on the street. This one was picked up at a flea market, and it's hanging in my room.

It is designed to be an ambient information device. When it is under computer control, you can run programs that collect information and output it on the traffic light. This "push" of information is supposed to keep you informed without your intervention.

But, mostly I did it because it's fun.

Best of all, you can build one, too! Scroll down for a schematic, parts list, and other downloadables.

Video

Some Potential Applications

USB Control

Autonomous

Pictures

Background

The original Traffic Light Hack was a huge success, being featured on Hack a day and in the book Makers. However, the original design was cumbersome, requiring multiple power outlets and a host computer with a parallel port for controlling the system.

The Traffic Light Hack Mark II is a complete design of the traffic light hack. It is run by a microcontroller that has a set of predefined light sequences in addition to a USB interface for direct computer control and in-circuit reprogramming of the microcontroller.

The circuit is based on the open Arduino platform. The embedded AVR ATmega168 can autonomously cycle the lights through any number of predefined patterns, or be controlled directly from a computer over an Arduino MiniUSB adapter.

Serial Control

These are examples of commands the microcontroller can interpret.

CommandAction
yIlluminate yellow only
+rIlluminate red in addition to previous lights
-rDim red from previous lights
fffaFlash all lights three times
FFgFlash green once for twice as long
+FFFFyFlash yellow once for four times as long (additive)
Dim all lights

Build it Yourself

Disclaimer

This circuit requires connecting to mainline power (120 V AC in the U.S.). This is quite dangerous, and you can easily hurt yourself or damage your computer. Always check all circuit continuities before plugging anything in. If you mess up, it's not my fault.

Important: A Warning About Relays

It has been suggested by the ever-civil commenters at Hack a day that driving relays directly from a microcontroller is, in short, a Very Bad Idea. The inductive coils can cause a high kickback voltage when they are suddenly closed, possibly damaging the microcontroller. They also require a large current draw, which microcontrollers are not designed to handle.

I've revised the schematic to include reverse-biased fast diodes in parallel with the relay coils. This limits the kickback voltage to 0.7V.

Ideally, the microcontroller would drive a transistor, which in turns allows 12 VDC to be applied to the relays. Also, a strictly solid-state solution, such as an opto-isolator replacing the relays, would be sufficient.

Schematic

Parts List

This spreadsheet is available on Google Docs and as an HTML page.

Design Choices

Arduino – The Arduino platform was a no-brainer. The components are cheap and readily available, the documentation is decent, and the development tools are free and cross-platform. Also, the language is dead-easy to learn and use.

Electromechanical relays – One commenter on the original hack mentioned that opto-isolated circuits would be safer than relays, physically isolating the low-voltage DC circuit and the high-voltage AC mainline power. This is true, but I have not had any trouble with the relays, and, more importantly, the relays provide tactile feedback in the form of a "click" when they switch over (think of the noise your car blinker makes).

Downloads