Led RGB con sensor infrarojo y control remoto



Código:

#include <IRremote.h>
int red = 9;
int green = 13;
int blue = 10;

int receiver = 11; // pin 1 of IR receiver to Arduino digital pin 11
IRrecv irrecv(receiver); // create instance of 'irrecv'
decode_results results;

void setup()
{
pinMode (red, OUTPUT);
pinMode (green, OUTPUT);
pinMode (blue, OUTPUT);
 
Serial.begin(9600); // for serial monitor output
irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
if (irrecv.decode(&results)) // have we received an IR signal?
{
Serial.println(results.value, HEX); // display it on serial monitor in hexadecimal
irrecv.resume(); // receive the next value
 
  if(results.value==0xFD08F7){
    digitalWrite(red,HIGH);
    digitalWrite(green,LOW);
    digitalWrite(blue,LOW);
}
  if(results.value==0xFD8877){
    digitalWrite(red,LOW);
    digitalWrite(green,HIGH);
    digitalWrite(blue,LOW);
 
}
 
  else if(results.value==0xFD48B7){
    digitalWrite(red,LOW);
    digitalWrite(green,LOW);
    digitalWrite(blue,HIGH);

}
  }
  delay(1000);
 
  }
 
 
 
 
 
 

Comentarios

Entradas populares de este blog

Alarma visual (Led con ultrasonido)

Sistema de turnos con led de 7 segmentos y pulsadores

Teclado matricial 4x4 con LCD