3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.


Arduino stoplight web server

Arduino stoplight web server
«
  • cropped-arduinostoplight.jpg
  • IMAG0134.jpg
  • IMAG0122.jpg
  • IMAG0131.jpg
At the place I work, we use xymon to monitor of our servers. All of the services monitored are important, but we wanted a separate indicator to simply show the overall health of the most critical systems. Furthermore, we came up with the following criteria:
  1. We wanted this visible to everyone whether or not they were near a web browser or even a monitor.
  2. We wanted it to preserve the "red/yellow/green" status's xymon uses.
  3. We wanted it to be stand alone, not requiring a separate computer (we already have one running a widescreen monitor elsewhere for that).
  4. We wanted it to look good and be fun.
After a little brainstorming, we decided a stoplight equipped with an ethernet enabled arduino would do the trick and I set out to build it.

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 adsRemove these ads by Signing Up
 

Step 1What you need

What you need
«
  • IMAG0079.jpg
  • DSCN2218.JPG
Below is a list of everything needed to buy if building from scratch. Don't let the $126 electronics bill scare you; there are a number of ways to save by scrounging and foregoing some cosmetic items. Aside from the Stoplight, the largest costs are the arduino and the Ethernet shield. Obviously if you have either of these items already, this project will cost considerably less (-$30 and -$44.44 ). The two enclosures are not strictly needed, particularly if you are going to stuff everything into a stop light (-$17.46 ). Any 9 volt power supply that can power the arduino can work. There is no need to buy this expensive one if you have one laying around (-$16.68 ). And finally, the ribbon cable (-$3.22 ) can be replaced by any 6 conductor cable or even just 6 wires, and probably doesn't need to be 4 feet depending on where you put the arduino and the power circuit.

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
total = $126.83


Other materials:

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

You can order all the mouser items from this project list, or start with that list and subtract anything you don't need. Mouser apparently didn't like all the traffic going right to their shopping card and deleted this project without notice. I'll be updating with actual part numbers later. If you are starting from scratch, make sure you add supplies like solder and wire. As of this writing, mouser does not carry the circuit breaker or stop lights.

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 StepDownload PDFView All StepsNext Step »
45 comments
1-40 of 45next »
May 2, 2012. 6:29 PMnickbart says:
Hey, just wanted to add to the accolades and say this was a great tutorial. Also wanted to let you know that I ended up getting a PCB made for this and it worked great. I also wrote a PHP class to make sending the HTTP quests easier. I posted a little write up on my blog, giving you due credit of course, and included photos of the PCB and the finished circuit:

http://su.percilio.us/2012/05/arduino-stoplight-web-server/

Thanks for the great work!
May 3, 2012. 7:18 AMnickbart says:
Yeah, the PCB seems to work great. I did have little trouble when only two of the relays seemed to be sending power to the screw terminal, but I think that was down to my soldering. I resoldered a number of the joints and it seemed to be fine after that.

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.
Feb 24, 2012. 3:39 AMghostman!! says:
Im not sure if its me doing something wrong, but when ever i try and use someone elses code from here, it never works !


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
Feb 24, 2012. 4:13 AMghostman!! says:
Errorrrrrr Errooorrrrrr


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
Oct 17, 2011. 6:47 PMbuckmeisterq says:
I hadn't done any soldering in a while, so as a way to ease into this project one of the first things I did was solder the headers to the ribbon cable - easy to fix and re-do if I screwed up (plenty of ribbon cable and extra headers).

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.
Oct 17, 2011. 6:55 PMbuckmeisterq says:
I used 20ga wire (or 22ga? it was solid wire rated for 300watts) for the 120v portion and nothing seems to be heating up or catching on fire yet. I didn't see a mention of a size for the 120v portion, but it seems like we're dealing with such a small amperage max (limited by the 5A fuse) that it should be OK.
Oct 17, 2011. 1:43 PMbuckmeisterq says:
I finally had time to finish my stoplight, thanks again mkanoap for this great instructable.

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.
Sep 28, 2011. 10:01 PMarduinopowered says:
Hi, im a small website server owner and i have built your project. Could you please possibly post an example script?
Sep 29, 2011. 2:02 AMarduinopowered says:
nervermind i worked it our, but for people who want to control it without a browser and dont know how heres is a basic html line you can add to control it

<.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)
Sep 25, 2011. 9:59 PMlesizz says:
So...I notice the traffic light in the picture is RED! So while you were taking pictures for this instructable for our benefit, your servers were flaming out.
Sep 22, 2011. 10:45 AMsing1ejack says:
Thanks for putting up such a great pricing and sourcing list, by the way. It's always discouraging to look at a great instructable and not be able to guess whether it's pie in the sky or actually doable. It's less intimidating when I have a link for unfamiliar parts and can identify the pricey parts (and brainstorm ways to bring down their cost).

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...
Sep 24, 2011. 1:28 AMbeehard44 says:
probably a way is to skip the standalone option and link it with a computer
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)
Sep 24, 2011. 1:30 AMbeehard44 says:
suggestion, make it dim the lights and activate red beacons if there is a really serious error
Sep 19, 2011. 12:52 PMbuckmeisterq says:
This is a really cool project and I'd like to give it a try myself (I'm a bit new to this arduino stuff but I've always had a knack for soldering).

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 :-)
Sep 22, 2011. 3:04 PMlesizz says:
Newark Electronics is another supplier option. They have the widest selection of any supplier I know of. And I think they have a parts list service.
Sep 22, 2011. 9:36 AMakahn2 says:
There's a great company in upstate NY just south of Albany that sells traffic signals and parts: http://www.twingreenonline.com/signals.htm , they have LED traffic lights and it's a lot cheaper than the site mentioned in the Instructable for either LED or incandescent signals.

Sep 22, 2011. 12:02 PMhammer9876 says:
Great idea. So much more high tech than what we had years ago. Each server was represented by a small toy animal that were kept on top of a cubical wall. When (not if) the server went down, someone would tip the toy nose-down. Everyone had to stand up to see if the Giraffe server was dead in the water, but the system worked.

I like your instructable better.
Sep 22, 2011. 6:52 AMjuanman80 says:
Hi, nice job!
for us, europeans that visit this place, what would we need to make this project with 220 V bulbs?
Sep 22, 2011. 7:19 AMsdtacoma says:
Great idea. I wish my work would adopt something like this.
Sep 21, 2011. 2:04 PMjneveln says:
Thanks for this write up. I've had a traffic light for years since I got one at a Dept. of Transportation surplus auction a long time ago. Not as long ago I got an Arduino and an EFX-TEK RC-4 relay board (http://www.efx-tek.com/topics/rc-4.html) to control it with, but was getting stuck on the little fiddly bits needed to connect it all up and where to get them. I went with the pre-made relay board so I didn't have to do as much on the 120 V side of things. This will help a lot.

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.
Sep 17, 2011. 2:58 PMellisgl says:
Now you can get the Arduino Ethernet board for $60. That should cut a little off the total cost.
1-40 of 45next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
18
Followers
5
Author:mkanoap
He's just this guy, you know?