Remote Controlling Home Appliance Using your TV Remote


Let’s learn to control our home appliance using the TV or DVD player remotes or smartphones phones like Xiaomi which is having an inbuilt IR transmitter.

We are using a Relay channel with an Arduino and IR receiver to control our home appliances.

If you haven’t watched the previous tutorial watch it before reading further. ????????

How to use IR remote with Arduino?

Hardware Used

ComponentsAmazon.comamazonBanggood.combanggoodAliExpressali expressUtsourceutsource
Arduino UNOcart iconcart iconcart iconcart icon
5v Relay Channelcart iconcart iconcart iconcart icon
IR Receiver Modulecart iconcart iconcart iconcart icon
Bread Boardcart iconcart iconcart iconcart icon
Jumper Wirescart iconcart iconcart iconcart icon

Software / Libraries Used

IR library for Arduinodownload icon
Arduino IDEdownload icon


Connect the circuit as shown below.

Arduino UNO with 2 channel relay and IR receiver.
ArduinoRelay ChannelIR Receiver Module



#include <IRremote.h>

int RECV_PIN = 11; //pin at which the OUT pin of IR receiver is connected

const int codeRelay1 = 2715722588; //replace your code here for relay1
const int codeRelay2 = 2715706268; //replace your code here for relay2

int code;

int relay1 = 9; //pin at which relay1 is connected
int relay2 = 8; //pin at which relay2 is connected

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
  // In case the interrupt driver crashes on setup, give a clue
  // to the user what's going on.
  Serial.println("Enabling IRin");
  irrecv.enableIRIn(); // Start the receiver
  Serial.println("Enabled IRin");
  pinMode(relay1, OUTPUT); digitalWrite(relay1, LOW);
  pinMode(relay2, OUTPUT); digitalWrite(relay2, LOW);

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, DEC);
    code = results.value, DEC;
    irrecv.resume(); // Receive the next value

  if (code == codeRelay1)
    if (digitalRead(relay1) == HIGH)
      digitalWrite(relay1, LOW);
      digitalWrite(relay1, HIGH);

    code = 0;
  else if (code == codeRelay2)
    if (digitalRead(relay2) == HIGH)
      digitalWrite(relay2, LOW);
      digitalWrite(relay2, HIGH);

    code = 0;


How to assign buttons to the relays?

  • First, upload the above code and open the serial monitor.
  • Then press the buttons on the IR remote which you want to assign to the relays.
  • So some values will be printed on the serial monitor for the press of each button.
  • Copie the code from the serial monitor and change it in the code where it is mentioned
const int codeRelay1 = 2715722588; //replace your code here for relay1
const int codeRelay2 = 2715706268; //replace your code here for relay2

  • Then upload the code again
  • Now if you press the same buttons which you assign then the relay will ON for the first press and it will OFF if pressed again

How to connect it to the home appliances?

Use the NO(normally open), C(common) & NC(normally closed) connections of the relays to connect to the high voltage appliances like fan, lights, etc…

To buy electronic components order from UTSOURCE

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top