how to design a relay switch using arduino

Hello,

I believe that the switch you are looking for is a SPDT switch. That stands for "single pull double throw." SPDTs are also referred to as "1 Form C" in technical applications, or "three way" switches in the United States (not sure about elsewhere). They are called three ways (even though you''d only use two switches in this application) becasue power to the device can either be cut off completely (state 1), through an upper set of contacts (state 2), or a lower set of contacts (state 3).

This is a great picture showing two of these switches doing what (I think) you want your circuit to do:

(original source http://ezdiyelectricity.com/images/wiringdiagrams/switches/3-way-switch-wiring-diagram.jpg)

Notice how ground and neutral wires are always connected, and only the hot wire is switched. Each of the two switches has one "pole," which can be "thrown" either up or down (again: single pole, double throw). If both poles are up, the circuit is complete and the light goes on. If both poles are down, the same thing happens. But if one is up and the other is down, then the circuit is broken and no power flows.

In order for an Arduino to take the place of one of these high voltage, high current switches, you have the option of using a mechanical relay, or a TRIAC (the "AC" in TRIAC stands for alternating current, which is very important). The relay will be easier to build, safer, and provides it's own measure of isolation from the Arduino. The TRIAC in this application would need an optoisolator to separate the low voltage Arduino from your high voltage source, and various other components to make it work correctly. The mechanical relay uses a small, built-in electromagnet that runs on low current and low voltage to make the connection on the high current, high voltage line.

Either way, you should have enough information to go and do some research for your particular setup, once I warn you that the power you are running into that lamp, often called "mains voltage," can kill you, blow up all of your stuff, or burn your building down. If you are not sure of what you are doing, seek additional help. Personally, I had years of experience with mains voltage before I ever knew there were off the shelf MCUs like the Arduino so I had (and still have) a lot to learn about interfacing the two, but I know how to deal with mains voltage safely. Please know your own limits and be safe.

Good luck!
-Jason