IR Remote Control for home appliances Using Arduino

0
136

Infrared (IR) sensors and remote controls will be used to operate light bulbs in this DIY project. An A1838B IR receiver serves as the IR sensor. Every time you press a button on a remote, a unique, coded IR signal is sent to the IR receiver. The infrared (IR) sensor will then pass this data along to the Arduino.

IR Transmission 

Infrared communication is a common, user-friendly, and inexpensive form of wireless communication. IR radiation is essentially invisible light to the human eye. The IR LED detects and operates at 980 nanometers (nm), which is close to infra-red. Due to its invisibility to the human eye, it is ideal for wireless communication. IR radiation is emitted by the sun, light bulbs, and numerous other sources.The only difference between IR light and visible light is that IR light has a longer wavelength. When you press a button on a TV remote, IR LEDs send information to the TV. An IR LED turns on and off 38,000 times per second to send information to the TV’s IR receiver.

Key Ideas

Pulse Width Modulation (PWM) 
The IR detector is an example of employing PWM for communication; it sends low pulses that may be analysed to ascertain what data the IR remote is providing.
Carrier signal 
The pulse lengths are transmitted via the IR remote using a 38,500 Hz remote signal.

IR Receiver Module 

The IR receiver is utilised to receive infrared rays released by the IR emitter. The module contains an infrared (IR) receiver.

Typically, IR receiver modules have three pins:

  • OUT
  • +Vcc
  • GND

Specifications
  • Working voltage: 2.7 ~ 5.5 V
  • Receiving angle: 90 °.
  • Working voltage: 2.7 ~ 5.5V.
  • Frequency: 38 kHz
  • Receiving range: 18m.
  • Working current: 1.8 mA
  • On-Board Power Indication LED
  • On-Board Signal Receiving Indication LED
  • Dimension: 18mm x 18mm x 11mm
  • Weight: 2

How Does It Function?

When a button is pressed on the remote, it transmits an encoded infrared signal. The IR receiver then receives and transmits this signal to the Arduino.

In the Arduino code, we will save the code for the buttons that will control the LEDs. When a button is pressed on the remote, the Arduino receives a code. The Arduino will compare this code with the previously saved codes, and if any match, it will turn on the LED associated with the button.

Required Hardware:

Interfacing Infrared Receiver TSOP1838 with Arduino

IR Receiver Arduino
OUT Pin 2
VCC 5V
GND GND

 

Interfacing Relay with Arduino

2 Channel Relay Arduino
VCC 5V
GND GND
IN1 Pin 3
IN2 Pin 4

Set up the IRremote Library 

  • IR REMOTE LIBRARY

To receive and interpret IR signals, we will install the IRremote library. The Arduino Library Manager contains this library.

Launch the Arduino IDE. Launch Sketch and select Include Library > Manage Libraries. Then hit Enter after typing “IRremote.” Install the following library:

After installing all the libraries, restart your IDE.

Arduino Sketch

Open your Arduino IDE and go to File > New. A new file will open. Copy the code given below in that file and save it.

IR REMOTE DECODING PROGRAM

We will send data to the receiver module using an IR remote control. This information will be decoded and used to control the Arduino board’s built-in LED.

#include <IRremote.h>
int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup(){
Serial.begin(9600);
irrecv.enableIRIn();
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, DEC);
delay(1000);
irrecv.resume();
}
}

Upload the code to arduino uno and open serial monitor. Press the power button on the remote to decode it. Use the decoded power button value to turn both lamps ON/OFF. Repeat for IR Remote buttons 1 and 2.

ARDUINO REMOTE CONTROL PROGRAM(Main Program)

#include <EEPROM.h>
#include <IRremote.h>
#define irPin 2
IRrecv irrecv(irPin);
decode_results results;
#define r1 3
int relay1 = LOW;
#define r2 4
int relay2 = LOW;
void setup() 
{
irrecv.enableIRIn();
pinMode(r1, OUTPUT); 
pinMode(r2, OUTPUT); 
digitalWrite(r1,0);
digitalWrite(r2,0); 
relay1 = EEPROM.read(0); 
relay2 = EEPROM.read(1); 
digitalWrite(r1,relay1); 
digitalWrite(r2,relay2); 
}
void loop() { 
if (irrecv.decode(&results)) {
switch (results.value) { 
case 2704://put the decoded value for power button
relay1 = ~ relay1;
digitalWrite(r1,relay1);
EEPROM.write(0, relay1);
digitalWrite(r2,relay1); //all off
EEPROM.write(1, relay1);
delay(250);
break; 
case 2064://put the decoded value for 1
relay1 = ~ relay1;
digitalWrite(r1,relay1);
EEPROM.write(0,relay1);
delay(250);
break; 
case 16://put the decoded value for 2
relay2 = ~ relay2;
digitalWrite(r2,relay2);
EEPROM.write(1,relay2);
delay(250);
break; 
} 
irrecv.resume();
}
}

LEAVE A REPLY

Please enter your comment!
Please enter your name here