ir remote control led 1

Remote controlled LED with Arduino

Share this

https://www.facebook.com/1828100427483348/videos/461946714311895/

How to program Arduino ir sensor code

Nowadays Infrared (IR) remote is widely used as wireless communication to control any appliances. There are many advantages of wireless technology.  TV/video remote controls, motion sensors, remote control toys, music player and infrared thermometers are a very prominent example of wireless communication using a remote control.

In this section, I am discussing a simple Arduino project of LEDs Control using Remote. In this project, I will also see how to set a particular key of remote for controlling a particular LED. Infrared Light is a Type of light but human eye can’t see. This light has a different wavelength and frequency from visible light. A lot of Infrared light also present in the environment in the sunlight.

When we press the key of remote, then a special intensity of frequency of infrared light emits through the IR LED connected in remote. That Emitted IR Signal is detected by the Sensor (photodiode or other IR sensors) and this decodes the ir signal and modulated by the circuit. Here I am using the HS0038 IR sensor for receiving and detecting the signal from the remote. You can use different ir sensor Like TSOP1738.

ir sensor

Connect the Positive terminal of a sensor with VCC of Arduino board and ground pin with the ground of Arduino. Now the Output pin of the sensor is connected with pin no 2 (you can connect with different digital output pin). Connect 10 LEDs,  positive terminal of all led with Pin no 4 to 13 in a series resistor of each LED 220 Ω. These are outputs that can be controlled by remote. 

Arduino ir sensor code

Step 1 : Download the Arduino-IRremote-2.1.0 zip file

Step 2 : Open Arduino (Arduino IDE)

step 3 : Go to sketch⇒ Include Library⇒ Add.ZIP library

Step 4 : Select your file and click enter

How to Decode The Remote

Copy the following code and paste  and then verify and upload to Arduino board

#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);
    irrecv.resume();
  }
}

Go to   Tools⇒ Serial Monitor

Then a blank page opened

Now press the key one by one (which keys you want to use) for instantly . You will see the some coded value for each key.

arduino ir decode

Then Copy and paste the following code in new or write as your own by the using of these coded value with place of CASE.

#include <IRremote.h>
#define irPin 2
IRrecv irrecv(irPin);
decode_results results;
#define r1 4
int relay1 = LOW;
#define r2 5
int relay2 = LOW;
#define r3 6
int relay3 = LOW;
#define r4 7
int relay4 = LOW;
#define r5 8
int relay5 = LOW;
#define r6 9
int relay6 = LOW;
#define r7 10
int relay7 = LOW;
#define r8 11
int relay8 = LOW;
#define r9 12
int relay9 = LOW;
#define r10 13
int relay10 = LOW;

void setup()
{
irrecv.enableIRIn();
pinMode(r1, OUTPUT);
pinMode(r2, OUTPUT);
pinMode(r3, OUTPUT);
pinMode(r4, OUTPUT);
pinMode(r5, OUTPUT);
pinMode(r6, OUTPUT);
pinMode(r7, OUTPUT);
pinMode(r8, OUTPUT);
pinMode(r9, OUTPUT);
pinMode(r10, OUTPUT);
}
void loop() {
if (irrecv.decode(&results)) {
switch (results.value) {
case 3772809343 :
digitalWrite(r1,0);
digitalWrite(r2,0);
digitalWrite(r3,0);
digitalWrite(r4,0);
digitalWrite(r5,0); //all off
digitalWrite(r6,0);
digitalWrite(r7,0);
digitalWrite(r8,0);
digitalWrite(r9,0);
digitalWrite(r10,0);
delay(250);

break;

case 3772793023 :
digitalWrite(r1,1);
digitalWrite(r2,1);
digitalWrite(r3,1);
digitalWrite(r4,1);
digitalWrite(r5,1); //all on
digitalWrite(r6,1);
digitalWrite(r7,1);
digitalWrite(r8,1);
digitalWrite(r9,1);
digitalWrite(r10,1);

break;

case 3772784863 :
relay1 = ~ relay1;
digitalWrite(r1,relay1);
delay(300);
break;
case 3772817503 :
relay2 = ~ relay2;
digitalWrite(r2,relay2);
delay(300);
break;
case 3772801183 :
relay3 = ~ relay3;
digitalWrite(r3,relay3);
delay(300);
break;
case 3772780783 :
relay4 = ~ relay4;
digitalWrite(r4,relay4);
delay(300);
break;
case 3772813423 :
relay5 = ~ relay5;
digitalWrite(r5,relay5);
delay(300);
break;
case 3772797103 :
relay6 = ~ relay6;
digitalWrite(r6,relay6);
delay(300);
break;
case 3772788943 :
relay7 = ~ relay7;
digitalWrite(r7,relay7);
delay(300);
break;
case 3772821583 :
relay8 = ~ relay8;
digitalWrite(r8,relay8);
delay(300);
break;
case 3772805263 :
relay9 = ~ relay9;
digitalWrite(r9,relay9);
delay(300);
break;
case 3772811383 :
relay10 = ~ relay10;
digitalWrite(r10,relay10);
delay(300);
break;

}

irrecv.resume();
}
}

Share this

Leave a Comment

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