Remote Controlled Switch Using Atmega 328p

Ever dreamt of controlling an appliance like a CFL or a fan at your finger tips and thinking for a cheap solution?

Well, then you are looking at the right instructable!!

This instructable will provide you with a cheap and best possible solution to control your switch operated appliances through an existing IR remote using a simple electronic circuit which uses an Atmega-328 microcontroller.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Things You Need for This Project.


  1. An existing IR remote(like TV remote).
  2. Atmega-328p Microcontroller-1
  3. IR Receiver Diode - TSOP38238
  4. 16 MHz crystal,10k ohm resistor and 22Pf Capacitor(2)
  5. 7805 voltage regulator
  6. 5v power supply(use any mobile charger if available)
  7. 4-channel relay board(Number of channel depends on the number of switches to be controlled)
  8. Arduino uno for testing and programming
  9. Some wire to connect to 220v supply


  1. For this project to be economical make sure to use atleast four switches. An additional switch only adds to a relay in the circuit. Hence more the number of switches less will be the cost per switch.
  2. Use 7805 voltage regulator only if you are using a supply capable of providing a voltage of 7 volts or above. If your supply voltage is anything less than this, it is safe to work without a regulator. Normally a mobile charger will not require a regulator.


  1. Bread board
  2. soldering gun
  3. wire strippper

Step 2: Selecting a Remote!

Today due to the advancement in technology every home will have atleast one remote.

As mentioned earlier any IR-remote which is available can be used for this project.

To obtain the IR protocol in which the available remote is working we need to have the value of the IR pulses the remote is transmitting for various buttons. In order to obtain the protocol we use Arduino Uno and IR Receiver Diode - TSOP38238 to decode the pulses emitted by the remote.

Connect the circuit as per the diagram above for IR circuit.

Note down the pulse values emitted by the buttons which you wish to use.

The firmware required for the above process is shared as IR Receive.

For more information about IR Remote and its protocols visit this link.

Step 3: Connections and Testing.

Once you are done with decoding of the pulses of the buttons of the remote its time to connect the actual circuit on a bread board.

For the purpose of testing rig up the same circuit which is used to decode the remote pulses and just include as many LEDs for the number of buttons you are planning to use.

The connections of LEDs to various pins depends on your choice, but make sure to change the pin numbers in the code according to your connections.

The code provided here is for 4 devices or LEDs. To add more just just replicate "cases" in the code.

For more information on the shared code visit this link.

Once done with the connections upload the code shared below.

After uploading the code you must be capable of controlling a particular LED from a particular button on your remote.

If you are familiar with the Relays then skip to step 5 to prepare your permanent board else follow the next step to learn how to connect a relay between a microcontroller and a switch of an appliance which you wish to control.

Step 4: Working With Relay!!!

Relay as the name defines itself "receive and pass on", an electrical device, typically incorporating an electromagnet, which is activated by a current or signal in one circuit to open or close another circuit.

A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid-state relays.

Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits).

For more information about Relays check out this link.

In our case here the low-power signal is the output signal(typically 5 volts) from the microcontroller which is used to control the switch which is operating at 220 volts AC.

A typical 5v/220v relay consists of an input terminal to which the input from the microcontroller is to be given and an output terminal to which the device which has to be controlled is connected.

There are two ways in which a relay's output terminal can be connected to a switch

1. Connecting Relay in parallel to a switch.

This is done by connecting the NO(normally open) and Common terminals of the relay to the two terminals of the switch. This type of connection ensures that the switch can be operated independently by either of two ways, i.e either manually or through the remote.

This provides an advantage that the switch can be operated manually even when the circuit is not working.

2. Connecting Relay in series with the switch.

This is done by connecting the NO(normally open) terminal to device and common to one terminal of the switch and other terminal of switch to the supply. This type of connection ensures that the switch is high only when it is both manually switched on and also through the remote.

Step 5: Perfboard Implementation..

When you are satisfied about the circuit and feel everything is working fine, its time to move on for further steps in implementing the circuit.

Solder the microcontroller circuit on a suitable sized perfboard according the circuit diagram.

Always use IC bases for mounting ICs instead of directly soldering them so as to avoid burning the IC while soldering or to have an option of upgrading the code in future.

Connect all the external circuits to the microcontroller like relay and supply circuit.

Step 6: Final Step!!

Be very careful working with high voltages!!!

Make sure to turn off the main circuit breaker in your home before opening the circuit panel.

Check if there is ample space available inside the circuit box to place your circuit. If the space is ample enough then make the necessary connections to your circuit and place your circuit and leave just the IR sensor out of the panel.

If the space inside the box is not enough then make a suitable enclosure made of either plastic or wood and place the box outside the panel.

Make sure the sensor is not masked and is clearly visible and do not place the sensor beyond 10 meters from the operating range.

Enjoy controlling the appliances at your finger tips:)!!!!

Suggestions and comments are always welcome:)

Thank you for reading this instructable!!!

Safety Challenge

Participated in the
Safety Challenge

Metal Contest

Participated in the
Metal Contest

Soldering Challenge

Participated in the
Soldering Challenge

2 People Made This Project!


  • CNC Contest

    CNC Contest
  • Make it Move

    Make it Move
  • Teacher Contest

    Teacher Contest

12 Discussions


Question 11 months ago on Step 6

When I purchase ic is it already programmed or I need coding to program it? Plz reply


1 year ago

how to connect the data in standalone relay if i am not using a relay module?


2 years ago

please! can you send me circuit daigram and programing code of the project..


3 years ago

hey thats a tata sky remote, do u have the ir codes of the remote. i want to make a arduino universal remote but after decoding the remote I'm not getting the right codes. and its showing Unknown codes and that codes are not working. will you help me in this.

1 reply
Sriram H Vrmalhotra2

Reply 3 years ago


Do you need the codes for all the buttons of that remote or just some?

The decoding is pretty easy but I think there is some error in IR receiver connection. Check the pin out of the particular TSOP receiver you are using.


3 years ago

Hi Sriram,

I wish to control only one lamp (max 100W). The other requirement would be to ensure very long life (10 or more years). Can you provide a circuit for that? I am assuming the relays would be solid state (I'm an electronics noob, so don't really know much). Since it is just one switch, there would be no need to decode the pulses, right?


1 reply
Sriram H VMarutiM

Reply 3 years ago


The circuit remains the same for one lamp of 100w rating. To increase the life you can use a Triac which will not have any mechanical parts in it. For triac connections just google it. BT136 triac would work fine for your application.

No decoding would be needed for a single lamp but it is better to code the IR signals just to make sure it does not trigger from false signals.


3 years ago

I only want to know where crystal can be connected without the use of arduino board


4 years ago

it would be nice to be able to turn off the appliance via the remote after it has been turned on manually by the switch.

if you put the switch on the low voltage side of the relay and put it's output through a logic gate or 2 along with the output of the microcontroller you'd be able to do that.

Or you could use the uControler to watch the status of the switch (also on the low voltage side of the relay) and if it changes it'll turn the appliance on/off. This way, you could also turn on or off with the remote, and simpler than using external logic chips. You might need more pins depending on the number of appliances, but you could use an I2c or SPI port extender for that.

Nice work otherwise.

1 reply