Thursday, December 11, 2014

IR Remote Control Code

*************************************************




#include <IRremote.h>
int RECV_PIN = 11;
int ledBlue = 2;
int ledYellow = 3;
int ledRed = 4;
// Remember to add 0x to the hexadecimal codes
long button1 = 0xAC516266;
long button2 = 0xAD5163FB;
long button3 = 0xBE15326E;
long button4 = 0x9FA96F;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
  Serial.begin(9600);
  pinMode(ledBlue, OUTPUT);
  pinMode(ledYellow, OUTPUT);
  pinMode(ledRed, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
  irrecv.blink13(true); // blink LED on P13 when IR signal is present
}
void loop() {
  if (irrecv.decode(&results)) {
    if (results.value == button1){digitalWrite(ledBlue, LOW);}
    if (results.value == button2){digitalWrite(ledYellow, LOW);}
    if (results.value == button3){digitalWrite(ledRed, LOW);}
    if (results.value == button4){
      digitalWrite(ledBlue, LOW);
      delay(10);
      digitalWrite(ledBlue, HIGH);
      delay(10);
      digitalWrite(ledYellow, LOW);
      delay(10);
      digitalWrite(ledYellow, HIGH);
      delay(10);
      digitalWrite(ledRed, LOW);
      delay(10);
       digitalWrite(ledRed, HIGH);
     
    }
    irrecv.resume(); // Receive the next value   
  }
}


**************************************

No comments:

Post a Comment