Project showcase
Control an LED with the Remote Control

Control an LED with the Remote Control

Receive the signal and control an LED.

  • 3,192 views
  • 2 comments
  • 9 respects

Components and supplies

Apps and online services

About this project

First of all you need to know the control codes of your remote control.

Connect only the IR sensor and run his code. Open the Serial Monitor and point the remote control to the receiver. Press the buttons and the respective codes will appear. Sometimes the code 0xffffffff can appear because you have pressed the button for too long.

Then connect the LED and run the code, where you have to insert the codes of the two buttons you want to use.

With a button you can turn on and off the LED. With the other one you can make the LED blink.

Code

Project codeArduino
#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   ");
  }
}
Infrared Receiver CodeArduino
#include <IRremote.h>

const int receiver=11;

IRrecv ir_receiver(receiver);
decode_results results;

void setup() {
 Serial.begin(9600);
 ir_receiver.enableIRIn();
}

void dump(const decode_results* results) {
  const int protocol=results->decode_type;
  Serial.print("Protocol: ");
  if (protocol==UNKNOWN){
    Serial.println("not recognized.");
    } 
    else{
      if(protocol==NEC){
        Serial.println("NEC");
        }
      else if(protocol==SONY){
        Serial.println("SONY");
        }
      else if(protocol==RC5){
        Serial.println("RC5");
        } else if(protocol==RC6){
            Serial.println("RC6");
            }
Serial.print("Value: ");
Serial.print(results->value, HEX);
Serial.print("(");
Serial.print(results->bits, DEC);
Serial.print(" bits)");
}
}

void loop() {
 if(ir_receiver.decode(&results)) {
   dump(&results);
   ir_receiver.resume();
   }
}

Schematics

circuit diagram
Ir led bb ds8betbova

Comments

Similar projects you might like

Wireless LED Lamp with IR Remote Control

Project showcase by Peter Wallhead

  • 4,067 views
  • 2 comments
  • 16 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 17,304 views
  • 4 comments
  • 34 respects

Servo Control with TV Remote Control

Project showcase by eldo85

  • 5,596 views
  • 5 comments
  • 17 respects

Turn LEDs On/Off via Remote Control

Project tutorial by ismystore

  • 7,098 views
  • 0 comments
  • 6 respects
Add projectSign up / Login