A desktop icon switches on and off a real desktop lamp (or anything else plugged into the outlet). This small tutorial illustrates how a multimedia application can control appliances plugged into an electrical outlet, such as a household appliance, a lamp, or a stereo …
The Arduino microcontroller works as an interface between the computer and the 220/110v circuit through a relay. Any application that accesses the virtual serial port will be able to control the power of the electrical outlet.
For simplicity we have created a BAT file with the following command line:
when clicked, sends the character k throught the virtual serial port # 6, which is where the arduino FTDI drivers is installed on my computer (check windows device manager to see wich is yours). In turn, the arduino switches the state of the output pin # 8 which is connected to the relay throught a resistor and a transistor. Finally, we have created a shortcut to the bat file and designed a desktop icon it.
The goal of the relay is to separate (and control) mechanicaly two distinct circuits – the arduino (5vdc) and the lamp (220 ac). Since the relay uses a coil to activate the switch sometimes the inducing effect can happen and give an wanted discharge in the opposite direction of the circuit. Therefore we must insert a diode between the relay terminals to protect the arduino from a short circuit.
The transistor is required to excite the relay, because the current supplied by the arduino’s pin may not be sufficient. At the base of the transistor we place a resistor (1k) to limit the current ( between the transistor and the pin of the microcontroller).
The output of the relay will depend of the kind of stuff to be controlled.
For most household appliances simply use as reference:
RN 2A 6VDC
Download – myLamp – desktop
Download – myLamp – processing.org