#include <IRremote.h>

 

IRrecv ricevitore(12); //crea istanza ricevitore (NON PIN 13)

decode_results results;

 

void setup()

{

Serial.begin(9600);

ricevitore.enableIRIn(); //avvia il ricevitore

pinMode(12, INPUT);

pinMode(9, OUTPUT);

pinMode(4, OUTPUT);

pinMode(5, OUTPUT);

digitalWrite(4, HIGH);

digitalWrite(5, LOW);

 

}

 

void loop()

{

 

if (ricevitore.decode(&results)){ //se c’è un segnale su target ricevitore

Serial.println(results.value,HEX);

 

switch (results.value){

case 0xFD30CF:

analogWrite(9, 255*0);

break;

 

case 0xFD08F7:

analogWrite(9, 255*0.1);

break;

 

case 0xFD8877:

analogWrite(9, 255*0.2);

break;

 

case 0xFD48B7:

analogWrite(9, 255*0.3);

break;

 

case 0xFD28D7:

analogWrite(9, 255*0.4);

break;

 

case 0xFDA857:

analogWrite(9, 255*0.5);

break;

 

case 0xFD6897:

analogWrite(9, 255*0.6);

break;

 

case 0xFD18E7:

analogWrite(9, 255*0.7);

break;

 

case 0xFD9867:

analogWrite(9, 255*0.8);

break;

 

case 0xFD58A7:

analogWrite(9, 255*0.9);

break;

 

}

 

ricevitore.resume();

}

}