Introduction: 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.
Step 1: Things You Need for This Project.
- An existing IR remote(like TV remote).
- Atmega-328p Microcontroller-1
- IR Receiver Diode - TSOP38238
- 16 MHz crystal,10k ohm resistor and 22Pf Capacitor(2)
- 7805 voltage regulator
- 5v power supply(use any mobile charger if available)
- 4-channel relay board(Number of channel depends on the number of switches to be controlled)
- Arduino uno for testing and programming
- Some wire to connect to 220v supply
- 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.
- 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.
- Bread board
- soldering gun
- 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!!!
2 People Made This Project!
We have a be nice policy.
Please be positive and constructive.