Network controlled stoplight

jesse

Touchdown! Greaser!
Joined
Oct 2, 2005
Messages
16,017
Location
...
Display Name

Display name:
Jesse
Thought this might be interesting to someone -- so decided to post it.

We've had a desire for awhile to use a stoplight to output the status of our continuous integration builds. Basically every time one of our developers commits code - automated systems start kicking off literally thousands of tests to verify that their change didn't break something. All of this is done before code is deployed into production.

For one reason or another it seemed like it'd be cool to have a big stoplight mounted in the office with it indicating the status of our continuous integration environment. The idea is that all code should be deployable -- what better way to encourage that behavior then a big light.

We came in contact with an electrical contractor that had an old stop light they didn't need anymore and gave to us:
1.jpg


Someone decided to place all my incoming packages in the most convient location...
6.jpg


It obviously needed some cleaning up:
2.jpg

3.jpg

4.jpg


Once things were cleaned up my first goal was to basically make sure I could get it lit up and functional. I replaced all the crap wiring inside and just made both lights go solid on:
5.jpg


Now that I had a clean stoplight that lit up and looked good it was time to figure out I was going to put it on the network, build a web server into it, and control the lights via REST like service.

There is a pretty cool project out there called Arduino -- an open-source electronics prototyping platform:
http://arduino.cc/
It seemed as if it'd work quite well for the job.

I settled on:
http://www.adafruit.com/products/418
It features a 16 Mhz processor, 32 kilobytes of flash memory, 14 digital I/O pins, 6 analog pins, and a 10/100 ethernet port. All for only $65.

The stoplight uses 110V AC. The Arduino board require somewhere between 7 to 12 volts. The pins one can turn on/off output 5 volts with a max of 40 ma. This presented a few problems.

It was my goal to build this all completely self contained inside the stoplight. So this meant that I needed to keep things pretty small. I found a 9 volt power supply that I could rip apart and easily mount in the stoplight. It worked out nicely for powering the Arduino.

My plan was to use a few relays for turning the lights on and off. The problem was that 40 ma of power at 5 volts wasn't enough to switch a large enough relay for the lights.

The 9V power supply used to power the Arudino would also provide adequate power for switching the relays. So then I needed some way to switch the 9V power on and off to each relay via the 5 volt pins.

I settled on using a transistor as a switch. A few relays (to switch the 110V AC on and off), a few transistors (to switch the relays on using the Arduino pins), a few resistors (to saturate the transistor), and a few diodes (to protect the transistor when the relay kicks off) and I was in business.

You can get an Arduino "prototype" shield for not much money:
https://www.adafruit.com/products/51

It just "stacks" onto the Arduino main board exposing all it's pins and giving you a nice way to build your own circuit.

A few pictures of the board with the switching components soldered on and ready for the first test:
7.jpg

8.jpg


A picture of the switching board I created stacked onto the Arduino:
9.jpg


The above easily fit inside the stoplight. I wired it up this evening and wrote a basic web server in C and uploaded it to the Arduino board and was able to turn the lights on and off via my web browser. Still working on the code..I'll post it when it's done.

Just kind of a fun project.
 
Last edited:
Those are fun. The software Devs at Polycom built one of those for their builds too.

Make sure you have a snubbing diode (or other method) across those relays for the kickback when they de-energize.

http://en.wikipedia.org/wiki/Snubber

Solid-state relays are a fun and interesting way to play that game also. Not really needed for a stop light (usually used for speed) but cool gadgets.

http://en.wikipedia.org/wiki/Solid-state_relay

Never played with the Aduino. Spent waaaaay too much time playing with the PIC micro-controllers though. Only a little low-level time with the AVR micro-controllers, which is what the Arduino is based on.

With some of the board shops you can get individual panelized boards single-sided without silkscreen so cheap these days from an Eagle file, it's amazing. A lot of the cheap board shops have their own board layout software these days too.

The Arduino in that regard is "expensive" in that a custom board and the micro-controller and associated hardware like a voltage regulator and a crystal (well, most will clock themselves these days but when I was playing you needed and external clock source) can be built for $10-$15 in small quantity.

The beauty of Arduino and other "systems" is that they've already dealt with the board layout, have huge codebases of shared code because the hardware is the same, and make throwing together something that works -- super fast. Especially all the little add on daughter-boards ("shields" in their terminology I think) that make interfacing to the "real-world" a breeze.

At the time I was losing interest (or just ran out of personal time to mess with it) the big killer app for AVR was avr-gcc. PIC was dominated by PIC BASIC Pro which was darn powerful and highly optimized, but if you were used to C programming, AVR was the way to go.

A little trolling around with Google after seeing your post seems to indicate that this is still the case.

Arduino is like the older BASIC Stamp was in the PIC micro-controller realm. A boot loader and some code already running hiding the complexities of the individual chips from the end-user so they can focus on their project by providing a running environment.

The main and add-on boards can get expensive if you do any project that requires quantity though.

Somewhere in the basement is a Motorola 68HC11 developers kit that was never even powered up, if you're in for some Assembly language pain. ;) ;) ;) Motorola was giving the things away for the cost of shipping once and since I started on a 6809 I figured it'd be fun to go back to my "roots", but frankly the PIC was doing everything I wanted at the time.

AVR micro-controllers were championed to me by a friend (now deceased) who loved their early lead on "single wire programming" or "serial programming" including on-circuit programming which was still coming of age back then. I had some PIC stuff that you had to pull the chip out of the circuit, stick it in the ZIF-socketed high-voltage programmer and wait to burn it, then throw it back in your circuit to see if you got it right. ;) Microchip caught up almost instantly to Atmel in that regard.

Definitely fun toys, no matter how you slice it.

If PCs still had real parallel ports, you could have done everything needed with the parport library on a Linux box and some optically isolated solid state relays. No need for a separate microcontroller at all! Just twiddle the parallel port bits in C. :) :) :)

Most of the USB to parallel converters don't play well with raw bit-banging, sadly. :(

This little guy is great if you just need to toggle crap on and off from Linux. (Well any OS...)

http://www.sparkfun.com/products/8265

Still kinda spendy for what it's made up of, but cheaper than a $65 Arduino. ;)
 
You know, as much as I'd love to fall in love with Arduino, I just can't. I've been banging out C code for the PIC for so many years, and doing things so cheaply because of it, I just can't find where it would fit for me. I'm glad to see people using them for stuff, though.

The stop light looks like fun. You should check www.bgmicro.com -- they often have LED traffic signal parts that can dramatically reduce the current and heat involved, and you could even rig up a PWM drive to dim them to a less annoying level so the signal is still useful once the novelty wears off. :) I also picked up some pretty stout solid-state relays there for under $5 each. I really like SSRs because you don't need to worry about back EMF or coil drive current requirements that exceed the capability of a PIC pin. Fewer parts = smaller and cheaper to produce.
 
Those are fun. The software Devs at Polycom built one of those for their builds too.

Make sure you have a snubbing diode (or other method) across those relays for the kickback when they de-energize.

http://en.wikipedia.org/wiki/Snubber
I mentioned the diodes in the post and they're in the picture as well. On the upper right portion there are three resistors, transistors, and diodes.

This little guy is great if you just need to toggle crap on and off from Linux. (Well any OS...)

http://www.sparkfun.com/products/8265

Still kinda spendy for what it's made up of, but cheaper than a $65 Arduino. ;)
I thought about things like that but it wasn't ideal. I wanted everything to be fully enclosed in the stoplight. Just plug an ethernet cord into the side of the stoplight and you're in business. I'd be needing to figure out the computer to drive that thing.

I don't really consider $65 expensive when you're not doing many and you're saving a bunch of time having someone else get the "environment" all ready for you.
 
You know, as much as I'd love to fall in love with Arduino, I just can't. I've been banging out C code for the PIC for so many years, and doing things so cheaply because of it, I just can't find where it would fit for me. I'm glad to see people using them for stuff, though.

The stop light looks like fun. You should check www.bgmicro.com -- they often have LED traffic signal parts that can dramatically reduce the current and heat involved, and you could even rig up a PWM drive to dim them to a less annoying level so the signal is still useful once the novelty wears off. :) I also picked up some pretty stout solid-state relays there for under $5 each. I really like SSRs because you don't need to worry about back EMF or coil drive current requirements that exceed the capability of a PIC pin. Fewer parts = smaller and cheaper to produce.

I might do the next one with solid state relays to get rid of the noise from the relays. But otherwise it was dirt cheap doing it like I did.

I changed the stoplight to 13 watt bulbs which really cooled it down and is still plenty bright.
 
Now interface that to a DMX board with audio sensing , add a disco ball and a few strobes ... bow chicka bow wow
 
my little sisters elementary school had a stoplight in the lunch room that was hooked to a decibel meter. When the kids got too loud it went yellow and then red. some sort of punishment was involved with hitting red, although i'm sure some kids considered it a contest to see if they could get it up there.

cool project Jesse, a friend has done some work with those arduino boards and made a self contained data logger with airspeed, altitude, and several other parameters for doing data collection on flights.
 
Small world, my BF is experimenting with Arduino and building stuff for fun in his spare time. Cool beans.
 
Yep I have one of those. My list of projects includes:

Air canon fired by a bluetooth cell phone.
Electric skateboard with a pwm controlled DC motor.

All of this after I get done soldering together my Megasquirt II EFI controller and get my 67 Camaro into the 20th century....

Love the projects guys...
 
Those Arduino boards are cool- great for small projects like this.
 
Well, he's got a traffic signal... what would be more appropriate (for a post-crash sound, no less) than a siren?

Yeah but it needs voice capability to announce the name of the (ir)responsible developer. ;)
 
Well, he's got a traffic signal... what would be more appropriate (for a post-crash sound, no less) than a siren?
Sounds like there'd be a need for a large display to show the offender's name.
 
Sounds like there'd be a need for a large display to show the offender's name.
He's got a big light... I've got code that will translate text to Morse code. Not that THAT would be really, really annoying or anything.
 
We're writing the code so you can send patterns to it

http://stoplight/loop/R1500,G1200,G0200,R0, etc, etc

That would turn on the red light, pause for 500 ms, then turn on the green line, pause for 200 ms, then turn off the green light, pause for 200 ms, turn red light off, and then repeat.
 
We're writing the code so you can send patterns to it

http://stoplight/loop/R1500,G1200,G0200,R0, etc, etc

That would turn on the red light, pause for 500 ms, then turn on the green line, pause for 200 ms, then turn off the green light, pause for 200 ms, turn red light off, and then repeat.
I've got an ASCII to Morse and Morse to ASCII translator routine around somewhere if you want it.
 
my little sisters elementary school had a stoplight in the lunch room that was hooked to a decibel meter. When the kids got too loud it went yellow and then red. some sort of punishment was involved with hitting red, although i'm sure some kids considered it a contest to see if they could get it up there.

cool project Jesse, a friend has done some work with those arduino boards and made a self contained data logger with airspeed, altitude, and several other parameters for doing data collection on flights.

That thing was the devil. I was oppressed in elementary school. If it went red we had to walk in circles instead of playing on the playground at recess. The teacher who enacted that policy lives in my neighborhood, she was super burned out and I'm pretty sure she enjoyed causing small children anguish. That was second grade.
 
That's pretty cool, Jesse. I'm afraid if you were testing my code, you would burn out the relay to the red bulb, and the green bulb relay would be stuck open from never being used. That's why I like being the sole developer on my project - I test it, if it doesn't work, I roll it back - nobody ever has to know how many iterations it takes to get it to work. ;)

Our project is developing apps that run on the forklift-mounted RF units. We talked at one time about putting .wav files on the RF's that could be played for certain events -- if the operator 'fakes' a scan and systematically moves inventory at a speed greater than a forklift could move it, we would play Charlie Sheen "You've been warned!"
 
Last edited:
Back
Top