The first thing anyone ever does on the Arduino board is to make an LED blink. Some go even so far as to call it the ‘Hello World’ of electronics. We took it a step further and made a Light bulb blink.
How is that different?
An LED works fine with a 2V DC supply voltage.
works with the household 220V AC supply. (or 110V, whatever the local power supply is)
|How many DIY'ers does it take to screw in a lightbulb?|
|Its not JUST orange juice.|
How we solved it?
After some research, and a lot of Pulpy Orange, we came across these magical little things called relays. No, not the one involving the baton, but the basic philosophy still holds good.
A relay is used when you need to control a circuit with a higher voltage with a low voltage signal.
When you input a digital HIGH (that’s 5 Volts) it shorts the other two leads with almost no physical connection between the two circuits. Something like this.
|The circle like thing is the light bulb and the rectangle is the relay.|
A digital HIGH connects the output circuit.
When you input a digital LOW (that’s 0 Volts) it leaves the other two leads open. This is like disconnecting the other circuit. Like this.
|A digital LOW disconnects the output circuit.|
So you can almost say the relay helps pass the baton from one circuit to the other. (You saw this coming:-P)
The Arduino can send and receive serial data via USB to the computer. We used a simple Physical pixel code from the Arduino website available here. What it basically does is,
if the Arduino receives an ASCII letter ‘H’ through the serial port then it sets the output pin to a digital HIGH. This eventually causes the light bulb to turn on because this HIGH is fed into the relay as shown above.
When the Arduino receives an ASCII letter ‘L’ through the serial port it sets the output pin to a digital LOW, which in turn turns the light bulb off.
We wanted a way to control the light bulb with an app on the computer. We basically built a simple GUI using the Processing tool. What it does is it basically uses a Java code to generate an application on the computer through which it sends serial data to the Arduino. Note that we didn't use the mouse-over program which Physical pixel used. But they both work the same way and work equally well.
So we used one of the example programs which creates a button and added a few things which makes it do what we want it to do. The code basically uses a
port.write() command to send the ASCII characters to the serial port a.k.a., the Arduino.
If you want the code we used its available here. It finally worked out in the end and you can see it in this video.
Well, the project isn’t all that high tech. We were just experimenting with a concept, and it worked. We want to expand on this idea and eventually have a completely automated room. There is a lot more to come. So stay tuned.