Stoplight controller details

It’s been a long time since I promised myself that I would post details of the stoplight controller. The controller is based on the Arduino Duemilanove, with a custom shield containing relays and connectors for the sensors.

The lights in the stop light itself are turned on and off by six 3A, 120V relays on the shield. The shield also has an independently controlled set of six LEDs and a few miniature buttons, mirroring the function of the main lights, switches, and sensors. The controller is housed in an 8″ plastic electrical box with a lexan cover. I have a bit of work to do yet to tidy up the wiring and strap down the transformer inside the box, but the  I cut a large hole in the side to hold the connectors for the sensors and button box, which use color-coded cat‑5 ethernet cables.

The distance sensors are Maxbotix LV-EZ1, which put out an analog signal that the shield passes along to the Arduino. The distance sensors fit perfectly inside these surface mount ethernet boxes with a 1/2″ hole drilled in them. Adding keystone jacks to the boxes makes connecting cheap cat‑5 cables simple and tidy. The sensors are mounted in front of each parking space. The Arduino runs a simple serial port interface program that can be used to program the controller with the threshold distances that change the light colors. The threshold distances are saved to the Arduino’s internal nonvolatile memory. The Arduino is positioned in the box such that the USB port is accessible from the outside, making updates and reprogramming simple.

The garage door open sensor is a C&K Components MPS80WGW magnetic switch. When the garage door opens, the magnet attached to the door moves away from the switch mounted by the door track, telling the controller that the garage door has opened. The controller then goes into parking mode, and changes the lights from green to yellow to red as the car pulls in.

A separate button box houses a couple great clicky arcade buttons that can make the controller perform some different light shows. The box is a simple 4″ grey plastic electrical box from the hardware store with a couple holes drilled in it, making it very durable.

Parking!

The garage door sensor and parking sensors are now installed and calibrated on the stop light controller! I know the video below is shaky — I’m experimenting on several levels here, so there will be better video as the project progresses.

When the garage door is opened, the controller checks for an empty parking space. If a space is empty, then the left and/or right stop light turns green. Then as the car pulls into its spot, the lights turn to yellow, then red as it reaches its exact parking spot.

Why it rules being an engineer

I’m told that I had a fascination with stop lights when I was little, watching them intently from my car seat in the back of our yellow Vista Cruiser station wagon. My dad decided that I should have one of my own, so he somehow obtained an old decommissioned unit from the Illinois highway department. I have no idea how exactly this was arranged, and I have purposely never asked to hear that specific story. I guess the transaction was legitimate, since there are plenty of stop lights for sale on eBay.  I have a very sketchy memory of backing the car up to a warehouse early on a grey Saturday and returning home with a beat up 100 lb stop light in the trunk. This was a very long time ago, so this memory could even be a fabrication. I also have vague memories of my dad in the basement refurbishing and painting it, fabricating shrouds to replace the mismatched, broken, and missing ones, and replacing broken lenses.

It has always been a goal of mine to give it an upgrade. There were any number of things that could be done, whether turning it into some kind of game, automating it, putting it on a timer, replacing the individual pushbutton switches with something fancier… this was a big project just waiting to happen and begging to have something done to it.

At some point last year I happened to learn about a project someone did, and it provided a spark of inspiration. This person had modified his Rancilio Silvia espresso machine, the same model we have, outfitting it with an LCD display, microcontroller that automated the brewing process and precisely controlled the boiler temperature, all controlled from a repurposed Wii Nunchuck. This was the project that led me to discover the Arduino community.

(I’d love to do the same thing to our espresso machine, but I don’t want to become the kind of person who requires my espresso to be brewed precisely at 196 degrees and at a pressure of 8 bars, and so forth. But it sure would be fun project to take on!)

On a more personal level, learning about other people’s Arduino projects assured me that this was the time to fix up that stop light and start having some fun! I learned about a handful of outfits on the web that cater to hobbyists and found some great arcade-style buttons, missile switches, and distance sensors, as well as a source for fabricating single copies of printed circuit boards. My dad, who originally indulged this whole stop light thing three decades ago, gave me an Arduino board for my last birthday, and so restarted the snowball.

After some initial tinkering with the Arduino to learn about how it all works, it was time to build a printed circuit board that would interface between the Arduino microcontroller and the stop light. I produced a schematic and PCB layout in Altium Designer, which is admittedly overkill, but if the tool is available, why not use it?

After an agonizingly long wait for BatchPCB to return the bare board (as they say, cheap and fast do not go together), I assembled the board and tweaked the microcontroller code that flashed the lights in sequence. The relays make a satisfying clicking sound when switching.

Currently, the controller implements six modes.

  1. The sequence mode turns the two sets of lights in a timed pattern, just as if at a regular intersection. The dwell time of each state is not currently programmable, but it will be eventually.
  2. A random flashing mode
  3. A railroad crossing mode that alternately flashes the left and right red lights
  4. A manual mode that is controlled via my MacBook’s serial console through the Arduino’s USB port. What’s the next logical step, a web interface? Emily will be thrilled!
  5. A parking mode that turns the lights from green to yellow to red as either of our two cars approaches its parking spot in the garage. The ultrasonic distance sensors are sensitive to about half an inch, and the current code allows the thresholds to be saved. Soon the cars can be parked farther back in the garage so as to maximize available space in the front of the garage. The parking mode is entered when the garage door is opened, tripping a magnetic switch attached to the garage door frame. No more hanging tennis balls from the ceiling!

Inspired by a “busy box” that my grandfather built out of dangerous old light bulbs, switches, buzzers, and motors, the brains of the stop light controller are visible through a Lexan cover. Connections to the button box, sensors, and indoor garage door open indicator are all color coded cat‑5 cables. There’s still more work yet to do, but it’s exciting to see progress on a project that has been 30 years in the making. Who knows, perhaps this old stop light was the toy that predisposed me to become an engineer?