Controlling LED's Using Remote Control - Arduino Project
Controlling LED's Using Remote Control - Arduino Project
HOME / PROJECTS, EMBEDDED, ARDUINO / CONTROLLING LED’S USING IR REMOTE CONTROL – ARDUINO PROJECT
dusuniot.com OPEN
This article allows you to turn ON and OFF LED’s using a cheap IR remote control. Here we used
Contents
an available IR Arduino library so it was pretty easy to decode the signals transmitted by the
infrared remote. 1 Required Components
2 Hardware
The LED’s which are connected to Arduino will be controlled by IR Transceiver module. IR 2.1 Circuit Diagram
Transmitter i.e., Remote transmits unique code to IR sensor wirelessly. IR sensor receives that 2.2 Circuit Diagram Explanation
signal and controls the LED’s which are connected to Arduino according to Code. 3 Software
3.1 Arduino Code
Required Components
3.2 Code Explanation
4 Working
5 Practical Implementation
6 Video
IR sensor
Arduino Uno
4 X Led’s
4 X 220 ohm resistors
Remote
Connecting wires
Breadboard
Hardware
Circuit Diagram
https://electrosome.com/led-control-ir-remote/ 1/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
After that, make the connections of the IR sensor with the Arduino as follows
dusuniot.com OPEN
Software
Arduino Code
https://electrosome.com/led-control-ir-remote/ 2/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
#include <IRremote.h>
int receiver_pin = 8;
int first_light_pin = 7;
int second_light_pin = 6;
int third_light_pin = 5;
int fourth_light_pin = 4;
int led_case[] = {0,0,0,0};
IRrecv receiver(receiver_pin);
decode_results output;
void setup()
{
Serial.begin(9600);
receiver.enableIRIn();
pinMode(first_light_pin, OUTPUT);
pinMode(second_light_pin, OUTPUT);
pinMode(third_light_pin, OUTPUT);
pinMode(fourth_light_pin, OUTPUT);
}
void loop()
{
if (receiver.decode(&output))
{
unsigned int value = output.value;
switch(value)
{
case code1:
if(led_case[1] == 1)
{
digitalWrite(first_light_pin, LOW);
led_case[1] = 0;
}
else
{
digitalWrite(first_light_pin, HIGH);
led_case[1] = 1;
}
break;
case code2:
if(led_case[2] == 1)
{
digitalWrite(second_light_pin, LOW);
led_case[2] = 0;
}
else
{
digitalWrite(second_light_pin, HIGH);
led_case[2] = 1;
}
break;
case code3:
if(led_case[3] == 1)
{
digitalWrite(third_light_pin, LOW);
led_case[3] = 0;
}
else
{
digitalWrite(third_light_pin, HIGH);
led_case[3] = 1;
}
https://electrosome.com/led-control-ir-remote/ 3/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
break;
case code4:
if(led_case[4] == 1)
{
digitalWrite(fourth_light_pin, LOW);
led_case[4] = 0;
}
else
{
digitalWrite(fourth_light_pin, HIGH);
led_case[4] = 1;
}
break;
}
Serial.println(value);
receiver.resume();
}
}
Code Explanation
First of all, we need to include the library for the IR sensor and IR remote. Then we initialized the pins where we connected the led’s
and set the initial state of the led’s as o state.
#include <IRremote.h>
int receiver_pin = 8;
int first_light_pin = 7;
int second_light_pin = 6;
int third_light_pin = 5;
int fourth_light_pin = 4;
int led_case[] = {0,0,0,0};
Then we de ned the code for each button through which we want to control the led. If you are running the Arduino code for the rst
time then upload the Arduino code as it is and open the Serial monitor. Press the button from the remote and a code will be shown
on the serial monitor for each button.
In the setup function, we have made the led pins as output pins because we will give the output to the led’s through that pins.
pinMode(first_light_pin, OUTPUT);
pinMode(second_light_pin, OUTPUT);
pinMode(third_light_pin, OUTPUT);
pinMode(fourth_light_pin, OUTPUT);
Whenever a button is pressed, a code is received by the IR sensor and is given to the Arduino. The Arduino will then compare it to
the already saved codes and if any of the code will match then it will turn on the led connected to that code. If the LED is already
light up and the same button is pressed again then the led will go down.
https://electrosome.com/led-control-ir-remote/ 4/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
if (receiver.decode(&output))
{
unsigned int value = output.value;
switch(value)
{
case code1:
if(led_case[1] == 1)
{
digitalWrite(first_light_pin, LOW);
led_case[1] = 0;
}
else
{
digitalWrite(first_light_pin, HIGH);
led_case[1] = 1;
}
break;
case code2:
if(led_case[2] == 1)
{
digitalWrite(second_light_pin, LOW);
led_case[2] = 0;
}
else
{
digitalWrite(second_light_pin, HIGH);
led_case[2] = 1;
}
break;
case code3:
if(led_case[3] == 1)
{
digitalWrite(third_light_pin, LOW);
led_case[3] = 0;
Working
Whenever a button is pressed on the IR remote, an IR led blinks thousands of time in a fraction of second and sends that data to the
IR receiver in the coded form. The IR receiver receives this signal and sends it to Arduino.
Each button has a unique code. So we have saved the codes for the buttons to which we want to control the LED’s in the Arduino
code. Now whenever a button is pressed, then an unique code will be received by the IR receiver and sends to Arduino. Then the
Arduino compares this received unique code with the saved codes. If any of the code matches with the Arduino pre-stored code
then Arduino will turn ON the appropriate LED light.
Practical Implementation
https://electrosome.com/led-control-ir-remote/ 5/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
Video
dusuniot.com OPEN
https://electrosome.com/led-control-ir-remote/ 6/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
Related Posts:
Controlling DC
Motors using Interfacing PIR Interfacing Soil Controlling of DC
Arduino and IR Motion Sensor with Moisture Sensor with Digital Door Lock Motors using
Remote Arduino Arduino using Arduino MPU5060
Author
Ali Hamza
Leave a Reply
Your email address will not be published. Required elds are marked *
Comment
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
POST COMMENT
https://electrosome.com/led-control-ir-remote/ 7/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
RELATED POSTS
Read More
RECENT POSTS
FOLLOW US
MOST VIEWED
https://electrosome.com/led-control-ir-remote/ 8/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
by Ligo George
What is a Microprocessor ?
by Ligo George
Transistor as a Switch
by Ligo George
CATEGORIES
Electronics
555 Circuits
Basic Electronics
Opamp
Electronics News
IC
Power Supply
Sensors
What is Inside?
Featured
Mobiles
News
Processors
Projects
Embedded
Arduino
AVR Microcontroller
ESP8266
PIC Microcontroller
Hobby Circuits
IoT
Softwares
Tablets
https://electrosome.com/led-control-ir-remote/ 9/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
Technology Transfer
Tutorials
8051 Microcontroller
8085
Arduino
ARM
ARM7
ATMEL AVR
CloudX
ESP8266
MATLAB
OpenWrt
PCB Designing
DipTrace
OrCad
PIC Microcontroller
CCS C Compiler
Hi-Tech C
MikroC
MPLAB XC8
Python
Raspberry Pi
Python Rpi
SCILAB
MOST COMMENTED
https://electrosome.com/led-control-ir-remote/ 10/11
12/13/2019 Controlling LED's using Remote Control - Arduino Project
TAGS
3D 16F877A 555 8051 MICROCONTROLLER ANDROID ARDUINO ARDUINO UNO ATMEGA32 ATMEL DC MOTOR DHT22
ELECTRONICS EMBEDDED ESP8266 GOOGLE HI-TECH C IOT L293D LCD LED MATLAB MICROCONTROLLER MIKROC
MOBILE MOTOR MPLAB MPLAB XC8 OP-AMP PCB PIC PROTEUS PWM PYTHON RASPBERRY PI RFID SAMSUNG
SENSOR SENSORS SERVO MOTOR SMARTPHONE TABLET TRANSISTOR TRANSISTORS TUTORIALS XC8
RECENT COMMENTS
FOLLOW US
https://electrosome.com/led-control-ir-remote/ 11/11