IR Receiver and IR Remote Tutorial
Hello guys, welcome back to my blog, This tutorial includes how to use IR receiver and IR remote with Arduino. This tutorial also covers how to turn an LED bulb and buzzer on and off with an IR remote using an IR receiver. Finally, there are step-by-step instructions on how to enable and disable several LEDs using an IR module (IR Receiver and IR Remote) and how to turn ON and OFF an 8-channel relay module.
What is IR Receiver and IR Remote?
The IR receiver works by using IR rays. These IR rays are also known as Infrared rays. These are invisible to our naked eye. Also, these rays have a longer wavelength than visible light. Therefore, these infrared rays are more suitable for wireless communication. We can see this technology in various appliances in the house such as TV, radio, fan. They remotely emit IR rays and are captured by the IR receiver in the electrical device. So we can do the relevant work. This IR receiver operates in the 38kHz band. For this reason, IR rays can be detected via the IR remote, bypassing other IR rays in the environment. This IR receiver also includes a filter called band-pass. It only emits 38KHz IR rays. The frequency is then converted to a binary number.
The different types of IR receivers are listed below.

We can see three main pins in these.

Signal – Get IR remote signals
VCC – This should provide a 2.5v – 5V potential.
GND – Cathode terminal should be connected to this.
Well, now we will learn how this IR receiver works with Arduino. The necessary accessories are given below. Here we show you how to ON/OFF an LED and Buzzer using any IR remote in the house using an IR receiver.
- Arduino UNO board x 1 — Amazon/ Our Store
- IR receiver x 1 — Our Store /Banggood
- LED bulb x 1 — Amazon/ Our Store
- 180-ohm resistor x 1 — Amazon/ Our Store
- 5v buzzer x 1 — Amazon/ Our Store
- Breadboard x 1 — Amazon/ Our Store
- Jumper wires — Amazon/ Our Store
- IR remote(You can use any IR remote at home for this)
OK, let’s do this project step by step.
Step1








Step 2

Step 3
Step 4
/*IR receiver circuit.
Serial monitor readings.
created by the SriTu Tech team.
Read the code below and use it for any of your creation
*/
#include <IRremote.h>//Include library
IRrecv IR(3);//create object and define arduino pin
decode_results result;//remote values
void setup() {
Serial.begin(9600);//enable serial monitor
IR.enableIRIn();//enable IR reciver
pinMode(4, OUTPUT);//define buzzer pin
pinMode(5, OUTPUT);//define led pin
}
void loop() {
if (IR.decode(&result)) {
Serial.println(result.value); //print your remote values
IR.resume();
}
delay(200);
long data = result.value;
switch (data) {
case 1: digitalWrite(4, HIGH);//press 1,buzzer on
break;
case 2: digitalWrite(4, LOW);//press 2,buzzer off
break;
case 3: digitalWrite(5, HIGH);//press 4,led on
break;
case 4: digitalWrite(5, LOW);//press 5,led off
break;
}
}
Code explanation
Step 5




Step 6

Step 7

Step 8
Well, now we will learn how to turn on / off four LED bulbs using an IR module. You can also use a relay module to replace this LED. Then you can control the electrical appliances in the house. This IR module includes an IR receiver and an IR remote. This also works in the same way as above. The accessories required for this are given below.
- Arduino UNO board x 1 — Amazon/Banggood
- IR Module x 1 — Amazon/Banggood
- LED bulb x 4 — Amazon/Banggood
- 180-ohm resistor x 4 — Amazon/Banggood
- Breadboard x 1 — Amazon/Banggood
- Jumper wires — Amazon/Banggood
Step 1






Step 2

Step 3
/*IR receiver circuit.
Serial monitor readings.
created by the SriTu Tech team.
Read the code below and use it for any of your creations.
*/
#include <IRremote.h>//Include library
IRrecv IR(2);//create object and define arduino pin
decode_results result;//remote values
#define value1 0
#define value2 0
#define value3 0
#define value4 0
bool LED1 = 0;
bool LED2 = 0;
bool LED3 = 0;
bool LED4 = 0;
void setup() {
Serial.begin(9600);//enable serial monitor
IR.enableIRIn();//enable IR reciver
pinMode(3, OUTPUT);//define LED 1
pinMode(4, OUTPUT);//define LED 2
pinMode(5, OUTPUT);//define LED 3
pinMode(6, OUTPUT);//define LED 4
}
void loop() {
if (IR.decode(&result)) {
Serial.println(result.value); //print your remote values
IR.resume();
}
delay(200);
if (result.value == value1 && LED1 == 0) {
digitalWrite(3, HIGH);
LED1 = 1;
result.value = 0;
} else if (result.value == value1 && LED1 == 1) {
digitalWrite(3, LOW);
LED1 = 0;
result.value = 0;
}
if (result.value == value2 && LED2 == 0) {
digitalWrite(4, HIGH);
LED2 = 1;
result.value = 0;
} else if (result.value == value2 && LED2 == 1) {
digitalWrite(4, LOW);
LED2 = 0;
result.value = 0;
}
if (result.value == value3 && LED3 == 0) {
digitalWrite(5, HIGH);
LED3 = 1;
result.value = 0;
} else if (result.value == value3 && LED3 == 1) {
digitalWrite(5, LOW);
LED3 = 0;
result.value = 0;
}
if (result.value == value4 && LED4 == 0) {
digitalWrite(6, HIGH);
LED4 = 1;
result.value = 0;
} else if (result.value == value4 && LED4 == 1) {
digitalWrite(6, LOW);
LED4 = 0;
result.value = 0;
}
}
Code explanation
Step 4




Step 5

Step 6

Step 7
- Arduino UNO board x 1 — Amazon/Banggood
- IR receiver x 1 — Amazon/Banggood
- 8-channel relay module x 1 — Amazon / Banggood
- Breadboard x 1 — Amazon/Banggood
- Jumper wires — Amazon/Banggood
- IR remote(For this, you can use any IR remote at home)
Step 1
Arduino UNO board

IR Receiver
8-channel Relay module

Breadboard
Jumper wires

IR remote
(adsbygoogle = window.adsbygoogle || []).push({});
Step 2

Step 3
Well now let’s make the necessary program for this. It is as follows.
The complete program of this project – Download
#include <IRremote.h>
#define PIN 2
#define Relay1 3
#define Relay2 4
#define Relay3 5
#define Relay4 6
#define Relay5 7
#define Relay6 8
#define Relay7 9
#define Relay8 10
IRrecv irrecv(PIN);
decode_results results;
#define remotevalue1 ""
#define remotevalue2 ""
#define remotevalue3 ""
#define remotevalue4 ""
#define remotevalue5 ""
#define remotevalue6 ""
#define remotevalue7 ""
#define remotevalue8 ""
byte relay1 = 0;
byte relay2 = 0;
byte relay3 = 0;
byte relay4 = 0;
byte relay5 = 0;
byte relay6 = 0;
byte relay7 = 0;
byte relay8 = 0;
long value;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(Relay1, OUTPUT);
pinMode(Relay2, OUTPUT);
pinMode(Relay3, OUTPUT);
pinMode(Relay4, OUTPUT);
pinMode(Relay5, OUTPUT);
pinMode(Relay6, OUTPUT);
pinMode(Relay7, OUTPUT);
pinMode(Relay8, OUTPUT);
for (int a = 3; a <= 10; a++ ) {
digitalWrite(a, HIGH);
}
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value);
value = (results.value);
irrecv.resume();
}
delay(400);
if (value == remotevalue1 && relay1 == 0 ) {
digitalWrite(Relay1, LOW);
relay1 = 1;
value = 0;
} else if (value == remotevalue1 && relay1 == 1 ) {
digitalWrite(Relay1, HIGH);
relay1 = 0;
value = 0;
}
if (value == remotevalue2 && relay2 == 0 ) {
digitalWrite(Relay2, LOW);
relay2 = 1;
value = 0;
} else if (value == remotevalue2 && relay2 == 1 ) {
digitalWrite(Relay2, HIGH);
relay2 = 0;
value = 0;
}
if (value == remotevalue3 && relay3 == 0 ) {
digitalWrite(Relay3, LOW);
relay3 = 1;
value = 0;
} else if (value == remotevalue3 && relay3 == 1 ) {
digitalWrite(Relay3, HIGH);
relay3 = 0;
value = 0;
}
if (value == remotevalue4 && relay4 == 0 ) {
digitalWrite(Relay4, LOW);
relay4 = 1;
value = 0;
} else if (value == remotevalue4 && relay4 == 1 ) {
digitalWrite(Relay4, HIGH);
relay4 = 0;
value = 0;
}
if (value == remotevalue5 && relay5 == 0 ) {
digitalWrite(Relay5, LOW);
relay5 = 1;
value = 0;
} else if (value == remotevalue5 && relay5 == 1 ) {
digitalWrite(Relay5, HIGH);
relay5 = 0;
value = 0;
}
if (value == remotevalue6 && relay6 == 0 ) {
digitalWrite(Relay6, LOW);
relay6 = 1;
value = 0;
} else if (value == remotevalue6 && relay6 == 1 ) {
digitalWrite(Relay6, HIGH);
relay6 = 0;
value = 0;
}
if (value == remotevalue7 && relay7 == 0 ) {
digitalWrite(Relay7, LOW);
relay7 = 1;
value = 0;
} else if (value == remotevalue7 && relay7 == 1 ) {
digitalWrite(Relay7, HIGH);
relay7 = 0;
value = 0;
}
if (value == remotevalue8 && relay8 == 0 ) {
digitalWrite(Relay8, LOW);
relay8 = 1;
value = 0;
} else if (value == remotevalue8 && relay8 == 1 ) {
digitalWrite(Relay8, HIGH);
relay8 = 0;
value = 0;
}
}
Code explanation
In the void loop, the values received over the IR remote are displayed on the serial monitor. Also, these values are added to the variable we previously named “value”.
Step 4
OK, now select the correct board and port. Afterward, upload this code to your Arduino board and run the Serial monitor.




Step 5


Step 6
