0% found this document useful (0 votes)
4 views2 pages

Project Code

This document contains an Arduino sketch for controlling an LED using an IR remote. It sets up an IR receiver and defines actions for specific button presses to turn the LED on, off, or make it blink. The code includes a loop that listens for IR signals and executes the corresponding actions based on the received command values.

Uploaded by

e22cs064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Project Code

This document contains an Arduino sketch for controlling an LED using an IR remote. It sets up an IR receiver and defines actions for specific button presses to turn the LED on, off, or make it blink. The code includes a loop that listens for IR signals and executes the corresponding actions based on the received command values.

Uploaded by

e22cs064
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

#include <IRremote.

h>

const int receiver = 11;


const int led = 9;

IRrecv ir_receiver(receiver);
decode_results results;

void setup()
{
Serial.begin(9600);
ir_receiver.enableIRIn();
pinMode(led, OUTPUT);
}

void loop()
{
if (ir_receiver.decode(&results))

{
Serial.println(results.value, HEX);
translateIR();
ir_receiver.resume();
delay(200);
}

void translateIR()

{
int sensorValue=0;
sensorValue = digitalRead(led);

switch(results.value){

case 0x20DF10EF:
if (sensorValue==0){

Serial.println(" ON ");
digitalWrite(led, HIGH);
break;
}
if (sensorValue==1){

Serial.println(" OFF ");


digitalWrite(led, LOW);
break;
}

case 0x20DFD02F:
if (sensorValue==0){
Serial.println(" BLINK ");
for(int i=1;i<5;i++){
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
break;
}
default:
Serial.println(" other button ");
}
}

You might also like