Site icon DIY Usthad

Remote Controlling Home Appliance Using your TV Remote

Arduino UNO IR Remote control

Introduction

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.comBanggood.comAliExpressUtsource
Arduino UNO
5v Relay Channel
IR Receiver Module
Bread Board
Jumper Wires

Software / Libraries Used

SoftwaresDownload
IR library for Arduino
Arduino IDE

Circuit

Connect the circuit as shown below.

ArduinoRelay ChannelIR Receiver Module
GNDGNDGND
5VVCCVCC
D11OUT
D9IN2
D8IN1

Video

Code


#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()
{
  Serial.begin(9600);
  // 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);
    else
      digitalWrite(relay1, HIGH);

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

    code = 0;
  }

  //delay(100);
}

How to assign buttons to the relays?

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

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

Exit mobile version