This question is mainly electronics related, but it also has a programming aspect.
Some background on the problem
We have a traffic light on a wall in our office. When people come in to the office, they can immediately tell from the traffic light whether last night's automatic build & test runs went smoothly: Green means all tests passed, yellow means some tests failed and red means some builds failed.
Right now, there are three switches on three cables hanging from the traffic light and someone has to manually toggle these every morning. I'm looking for an easy way to automate this process with a PC.
Some background on me
I can write software. I have some soldering experience. I know digital design theory, but I've never built a physical device. I don't have a lot of time on my hands.
The question
How can I control three 110V lightbulbs (or any device) from a PC with the minimum amount of effort (and investment)?
Some lax constraints
- I don't care about the effort to write the software to control a serial/USB port.
- Having said that, it would be nice if I don't have to write any software and just use existing tools.
- I prefer not to do any soldering! I can go with one of those hobby kits where you push components into slots etc. Or perhaps it could be something from Toys "R" Us.
- I'm willing to purchase an existing device like an Arduino board.
- It would be nice if I can get this done with just parts that are lying around. For instance, I have an old 2400Bd modem that I can take apart (though, that would probably be followed by some soldering).
Update
Similar projects that are mentioned in the answers:
"Red Bear Alert!" - The Hudson Bear Lamps
(source: magnetiq.com)-
(source: magnetiq.com) Bubble, Bubble, Build's In Trouble
(source: magnetiq.com)
An arduino board seems like overkill for something this specific, espeacially if you aren't going to be using it with conjunction with anything else. Plus you are going to have to buy a variety of components or an arduino shield (specifically the relay shield) so it'll quickly add up, especially if you don't want to solder (you will be looking at about $120+tax for the arduino and the shield.)
Since you are switching AC (the lightbulb) and the computer gives out DC, you will need relays. Also you will need to switch the relays with transistors as I don't think the output from serial or usb will output the mA you want.
The easiest way to go about this is to use a USB relay board. Something like this would work great http://www.robotshop.us/phidgets-1014-relay-interface.html. Plus its 1/3 of the price of the earlier combination. Even better they give you libraries to control it so programming is a breeze.
Also if you go on eBay you can get them even cheaper, especially if you don't mind using the now "antique" parallel port instead. I don't think you'll get libraries though.
Good luck
Look into X10
(Edit: replaced original posters NSFW link with wikipedia page on X10)
Get a USB traffic light and a USB extension cord. I gravitate toward the simplest solution possible. Should be pretty easy to write some software to drive it.
Just to give some more options:
Relays can be replaced by thyristors. These don't suffer from mechanical wear..
Another cheap and easy solution: Buy a cheap three channel light organ and connect it to the sound output of a pc. Find the resonant frequencies of the three outputs by playing back some test sine-tones or a sine-sweep.
That way you can not only toggle the three lights, you can dim and pulsate the lights as well. No need to mess around with USB and relays.
This device "IP Power 9258" should work for you, it is an ethernet comtrolled power bar. It is similar to the device used in this project "Red Bear Alert!" - The Hudson Bear Lamps.
A google search for relay controlled power strip, lists tons of projects to build your own.
I found a guy who built a full fledged traffic light here: http://people.usm.maine.edu/houser/bblight/index.html. Looks like more work than you want to do though.
You'll need:
- an
open collector output board
(like USB Interface Card Module VM110) and - some
12V relays
(like Omron G5LE-14 SPDT)
You may use you PC's 12V to power the relay coil.
Boards usually come with drivers and libraries to control them.
The X-10 modules are likely the easiest path to take. If you try to do 110 V switching on your own, your project will quickly become a hardware project rather than a software one. X-10 (used to?) have a dongle that plugs onto a serial port (called a "firecracker"). The protocol for that can be found online.
Final caveat: X-10 is kind of low-tech and subject to interference from modern switching power supplies. So try it in your office before committing to the software effort.
Use a serial port, which drives a H-bridge (you can get a chip off digikey) which drives a relay (digikey again). The H bridge electrically isolates the serial port and limits the current draw. It's not possible to switch wall current with a transistor, so that's why you use a relay.
Most PC components will not handle 115 VAC. You could take a look at some the stuff from x10 which is an old home automation standard. Other wise you will need to use relays controlled by a PC to switch the 115 VAC.
If you enjoy doing it yourself, a serial port interface wouldn't be too difficult. A serial port has at least two lines that can be switched on/off: RTS/CTS and DSR/DTR. When you turn either line on, you're getting +5VDC on that particular line. You can use those lines to control relays that in turn switch the lights on/off.
Here's one big issue: If I'm TC'ing that day, I can't see your light. Considering that, I'd build this as a little light that sits in the tray and shows the current build status. People that want to know the build status can install it, people that don't care won't be bothered by your intrusive traffic light. I heard a presentation from a consultant once and he said he'd done this at one company and the VP types just loved it. Here's one link; the sample is in Python.
Edit: Seems CruiseControl.NET has this sort of thing already.
Ever think of trying phidgets? (www.phidgets.com)
USB Power relays:
来源:https://stackoverflow.com/questions/451066/whats-the-easiest-most-practical-way-to-toggle-several-lightbulbs-with-a-pc