- We wanted this visible to everyone whether or not they were near a web browser or even a monitor.
- We wanted it to preserve the "red/yellow/green" status's xymon uses.
- We wanted it to be stand alone, not requiring a separate computer (we already have one running a widescreen monitor elsewhere for that).
- We wanted it to look good and be fun.
This article will be of particular interest to you if any of these apply:
- You have a stoplight that you wish could be controlled by a web browser.
- You would you like to learn how to safely control 120volt lamps from an arduino.
- You would you like to learn how to turn an ethernet shield equipped arduino into a simple web server to control outputs.
- You have a "red/green" monitoring system that you would like to have a visible, fun, hard-to-overlook physical component.
I'd sure love to have my own laser cutter. Please see the notes at the end for thoughts on how I would use one, and if you like this article, please rate it and vote for it in the laser challenge.
Remove these ads by
Signing UpStep 1What you need
You will need the following tools:
- Soldering iron
- Dremel or other tool to cut and shape the enclosures if needed
- Diagonal cutters
- Hot glue gun (optional)
- Vice or Helping Hands to hold the board while soldering (optional, but recommended)
- Multimeter (for testing the circuit before applying live power)
- Wire wrap tool (optional)
Electronics (Prices in US $ from mouser.com)
| 4- | 1K resistor | -- 4 X $0.06 = $0.24 |
| 1- | arduino | -- $30.00 |
| 1- | ethernet shield | -- $44.44 |
| 1- | arduino enclosure | -- $13.33 (optional) |
| 4- | NPN Transistors 2N3904 | -- 4 X $0.02 = $0.08 |
| 4- | Diodes 1N4004 | -- 4 X $0.06 = $0.24 |
| 6- | break off headers from 32 pin strip | -- $0.66 (Optional, and a strip of 36 is 30 more than needed for this project) |
| 1- | 9 pin ribbon cable | -- 4 X $0.64 = $2.56 (4 feet, strip off 3 extra conductors and trim to size) |
| 1- | 3 X 2 row break off headers from 10 X 2 strip | -- $0.65 (7 more than needed, break of 3 columns) |
| 1- | 9 volt power supply | -- $14.30 (any 9 volt power supply should work) |
| 1- | power cord for 9v power supply | -- $2.38 (the power supply I ordered didn't come with a cord!) |
| 1- | screw terminal block with 6 positions | -- $1.00 |
| 1- | 2x3 socket for ribbon cable | -- $0.66 |
| 1- | protoboard and enclosure (BusBoard KIT-1593L-BK) | -- $9.13 |
| 4- | 9 volt relays (fujitsu lz-9HE) | -- 4 X $1.85 = $7.40 |
| 4- | 1 Kohm resistors | -- 4 $0.04 = $0.24 |
Other materials:
- Solder
- Wire (at least 22 gauge for the 120v part of the circuit, 18 for stoplight wiring)
- Twist on Wire connectors (for splicing wires inside the light together)
- Power cord (I used one from a PC)
- Working Stop light (http://www.trafficlights.com/polysigs.htm ) -- $199 (www.twingreenonline.com has a nice selection of used lights for much cheaper)
- Mounting hardware for light -- (http://www.trafficlights.com/polysigs.htm#WMF ) -- $99
- 5 amp circuit breaker or fuse -- (www.grainger.com ) -- $3.38
For testing and hacking the following may be desirable, but are strictly optional:
- Breadboard
- Resistors (180 ohms each will do)
- One each of a Red, Yellow and Green LED
Stop lights can found on ebay or on the side of the road after a really good storm*.
* Not really, but you can find them on ebay.
| « Previous Step | Download PDFView All Steps | Next Step » |

























































http://su.percilio.us/2012/05/arduino-stoplight-web-server/
Thanks for the great work!
Thank you for your kind words and for testing the gerber file for me. :) It's really cool to see the printed version of the board.
I'll update the article to indicate it's a valid board.
I noticed that you put in the 4th relay. Are you using it for anything?
I did install the fourth relay, mostly because I thought I MIGHT use it and the relays came in a pack of eight, but we are not currently using it for anything. It does click whenever you send it a "beacon" command, but, for now, that's all it does.
stopduino.cpp:12:23: error: SdFatUtil.h: No such file or directory
stopduino.cpp: In function 'void setup()':
stopduino:97: error: 'FreeRam' was not declared in this scope
stopduino.cpp: In function 'void loop()':
stopduino:156: error: 'FreeRam' was not declared in this scope
Not sure :S
Since I ended up not doing that, I commented out the line that loads "sdfat.h". But the lines that print the free ram use a function that is in sdfatutil.h, and I forgot that it didn't come with the arduino.
I'll update the article to reflect this library later today.
In the mean time, you have two choices.
1) download and install sdfat from the link above.
2) comment out the line that loads sdfatutil.h AND all for lines that refer to "FreeRAM"
Let me know if this helps or if you need any further assistence.
http://stopduino.googlecode.com/svn/trunk/stopduino/stopduino.pde
Let me know if this fixes everything for you.
stopduino.pde:-1: error: cannot declare parameter 'client' to be of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: because the following virtual functions are pure within 'Client':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:12: note: virtual size_t Client::write(uint8_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:13: note: virtual size_t Client::write(const uint8_t*, size_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:14: note: virtual int Client::available()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:15: note: virtual int Client::read()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:17: note: virtual int Client::peek()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:18: note: virtual void Client::flush()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:10: note: virtual int Client::connect(IPAddress, uint16_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:11: note: virtual int Client::connect(const char*, uint16_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:16: note: virtual int Client::read(uint8_t*, size_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:19: note: virtual void Client::stop()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:20: note: virtual uint8_t Client::connected()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:21: note: virtual Client::operator bool()
stopduino.pde:-1: error: cannot declare parameter 'client' to be of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
stopduino.pde:-1: error: no matching function for call to 'Server::Server(int)'
As of Arduino 1.0, the Server class in the Ethernet library has been renamed to EthernetServer.
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:4: note: candidates are: Server::Server()
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:4: note: Server::Server(const Server&)
stopduino.pde:-1: error: cannot declare variable 'server' to be of abstract type 'Server'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:4: note: because the following virtual functions are pure within 'Server':
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:48: note: virtual size_t Print::write(uint8_t)
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:6: note: virtual void Server::begin()
stopduino.pde:-1: error: cannot declare parameter 'client' to be of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
stopduino.cpp: In function 'void doform(Client)':
stopduino.pde:-1: error: cannot allocate an object of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
stopduino.cpp: At global scope:
stopduino.pde:-1: error: cannot declare parameter 'client' to be of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
stopduino.cpp: In function 'void loop()':
stopduino.pde:-1: error: 'class Server' has no member named 'available'
stopduino.pde:-1: error: cannot declare variable 'client' to be of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
stopduino.pde:-1: error: cannot allocate an object of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
stopduino.pde:-1: error: cannot allocate an object of abstract type 'Client'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
I can't really update the actual stoplight because it's doing it's job in production, but I have another ethernet shield I can experiment with. I'll try to make a version that works with 1.0 this coming week, since other people are likely to run into this in the future.
In the mean time, you could probably just install an earlier version of the arduino IDE and (with the library mentioned on the comment above) have it compile. If you are using an UNO, I believe you need to have installed 1.0 first because it provides a driver for it, but you can have multiple versions of the IDE on the same machine.
When I came back to this step to attach the 6-pin connector after doing the rest of the project I realized I could just make out the location of the red marked cable in this picture of the connector and the ribbon cable - at this orientation the red is on the top. It was easy enough to confirm with my digital multimeter as well but I didn't want to crimp it the wrong way and (I think) ruin the connector.
It would be important if the pins were set in a socket matching the header, which would be a much more elegant way of doing it than the 6 bare pins I recommended.
I've added a note in the picture to show which one was the red one for those with less sharp eyes than you, and added a bit more info to the following step. Thanks again for the feedback!
20 is good for 11, so you are twice as good. :)
I ended up purchasing the LED model stoplight from LightsToGo LLC - it really didn't have room inside the lights to put much of anything (except the 5amp fuse) so I have my boxes outside the stoplight.
Here's my mouser list of parts in case anyone else is interested, I started without any parts, just tools:
1 - 2x3 socket for ribbon cable: 649-71600-106LF
5 ft (plenty extra) - 9 pin ribbon cable: 523-191-2801-109
1 - 9 volt power supply: 552-PSC-12R-090-R
4- NPN Transistor: 863-2N3904RLRAG
1 - Arduino kit (the breadboard and jumpers similar to what's in the LED test setup): 782-A000032
4 - Relays: 817-LZ-9HE
1 - 36 pin block of headers: 649-68001-436HLF
4 - Diodes (rectifiers): 625-1N4004-E3/54
I couldn't find the right screw terminal blocks on mouser (the ones I bought didn't have legs to solder through the PCB). I found them at Radio Shack 2761388 PCB Term 2P 5MM. I also bought 22 gauge wire there, as I said I really didn't have any materials when I started.
A friend gave me some 1/2 watt 1K ohm resistors, they weren't in the list but they're needed.
This is some other stuff I got that is pretty obvious but I'll list it anyway:
1 - Arduino Ethernet shield: 782-A000056
1 - Arduino board (it is the Uno): 782-A000046
1- Arduino enclosure: 782-A000009
3 - Red/Yellow LEDs: 606-4301F11/17
3 - Red/Green diffused LEDs: 607-4301F1/5
6 - 1/2 watt 180 ohm resistors: 660-MF1/12LCT52R181G
I'm a newbie and I wanted to follow the instructions as closely as possible so as not to mess myself up by diverging too much from the original project. It was tedious wiring everything on the protoboard myself. If we like this stoplight as a way to get notifications on the build I'm probably going to build some more, and I'll have the PCB printed for me at that point - maybe even dabble with POE, or try making it wireless somehow.
I was going to say "what do you mean the resistors aren't listed?" But then I checked and saw that yup, they are on the schematic, but not on the parts list!
Sorry about that! All I can say is that they WERE on the project list that mouser deleted. :)
I'll update the article to reflect the missing resistors, and see if I can't dig up the screw terminal block part number.
<.script GET src ="http://stoplight:port/bsecretredgreen"/>
is an example of turning red and green on
except get rid of the dot before script(its just so instructables doesnt treat it as a html line)
But seriously, two important points.
1) It's a good policy to alert BEFORE a server is in an unusable state. Red might mean "the disk is 90% full" or "cpu load is twice as high as normal" as well as "server not responding."
2) If you don't yet have your monitoring system hooked up, this light just displays whatever you last set it to with the web gui.
Actually, I would love for instructables to give authors a structured way to list the materials. Perhaps a search-as-you-type field that would then provide resource links and average prices. I know they're resourceful enough to do make this happen...
Maybe home servers would benefit from this because they can attach it to the server itself (which could save the user from a trip to where it is placed, which is usually hidden)
Some of the articles that appear automajically to the right of this one also may be pertinent.
If you don't need the Ethernet ability, you can save $45 right off the bat.
It was an even better list before mouser deleted the project so people can't just put it in their shopping cart. :)
I like the idea of dimming the lights for added drama.
The mouser project links take me to an "arduino" project that only has 4 items listed, and when I try searching for the "NPN Transistors 2N3904" there are dozens to choose from.
Also I'd be interested in finding out more about which arduino ethernet board would be the drop-in replacement? (I found 4 in a search on mouser).
And one more request, sorry, any recommendations on where to get the PCB printed? If this first one works well I might make a few more :-)
I'll try to figure out the part numbers from PO and update the article tomorrow, maybe with digikey parts. :) Honestly though, I just picked the cheapest. 863-2N3904RLRAG is a whole 3 cents cheaper and should do fine for those transistors.
The ethernet arduinos are hot off the presses, so I'm just speculating here. I'm thinking A000050 would be the closest replacement. Note that this model requires a special cable/adapter, not just a regular USB cable. It looks like A000060 is the same thing with the the new version of that adapter stuck on.
The other two you found are versions of those two with POE (power over ethernet). I would have LOVED to have built this with POE and eliminated the separate 9 volt adapter, but it was not yet available. Most switches don't provide POE, so don't bother with those unless you know you can use it.
I have had good luck with http://batchpcb.com for getting single boards printed at $2.50 per square inch plus $10 setup per board. But you have to wait a few weeks sometimes for a board to fill up. This board is about 7.5 square inches so it would be around $29.
Similar services I want to try but have not yet are:
http://dorkbotpdx.org/wiki/pcb_order ($5 per square inch, no setup and you get three copies! But you also have to wait for a panel to fill up with other people's orders. That would be $37.50, but only $12.50 each if you needed all three
http://iteadstudio.com/store/index.php?cPath=19_20 ($24.90 up to 10cm X 10cm (which would probably fit this board), and you get 10 copies!) You could throw out 9 and still be cheaper, or use all 10 at $2.49 each!
I like your instructable better.
for us, europeans that visit this place, what would we need to make this project with 220 V bulbs?
Also, I know nothing about European wiring codes.
I will however say this:
1) Those relays are rated for 2.5 amps at 240 volts each, so they should not melt or anything.
2) The calculations I made for the "don't plug more than this in" rely on the equation "current (amps) = watts/volts". So I looked at the bulbs (40 watts originally), added all three together and got 120 watts. It's easy to divide 120W/120V, so I knew that the lights would be drawing 1 amp max. That told me a 5 amp fuse would be plenty, and leave room for current draw from the optional socket. So the key number to consider would the be the wattage of the bulbs. If (for example) you had 60 watt bulbs, the calculation would be (3 X 60) / 220 = .82 amps. Still plenty enough to kill you if it crosses your heart, but even less amps than the 120 volt version.
So I'll tentatively say that the only modifications to the instructions would be for the plug, which I didn't have a picture of anyway.
If anyone sees anything blatantly wrong with the above assumptions, please comment before something tragic happens.
I plan to set mine up a bit differently, adding some other sensors like a distance sensor so I can put it in the garage and have it tell me when to stop, or an audio or stereo connector so it will blink in time to music. Plus just do normal traffic light-style blinking.
That board looks pretty nice and cheaper than getting a single copy of my (hypothetical) board printed. It's too bad the cost of the Solid State Relays drive it back up again, but it's still an attractive alternative.
I wish it had been out when I built this.