#include "IRLibAll.h" // contains all popular codes //Create a receiver object to listen on pin 2 IRrecv myReceiver(2); //Create a decoder object //IRdecodeGICable myDecoder; //IRdecodeSony myDecoder; //IRdecodeNECx myDecoder; IRdecode myDecoder; int16_t pos; // variable for print out #define led0 3 #define led1 4 #define led2 5 #define led3 6 #define led4 7 #define led5 8 #define led6 9 #define led7 10 #define led8 11 #define led9 12 #define toggle 13 void setup() { Serial.begin(9600); pinMode(3,OUTPUT); pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(8,OUTPUT); pinMode(9,OUTPUT); pinMode(10,OUTPUT); pinMode(11,OUTPUT); pinMode(12,OUTPUT); pinMode(13,OUTPUT); delay(2000); while (!Serial); //delay for Leonardo myReceiver.enableIRIn(); // Start the receiver Serial.println(F("Ready to receive IR signals")); digitalWrite(led0,HIGH); } //#define MYPROTOCOL NECx1 //GICable Sony #define BUTTON_0 0xa55ab847 //0x910 0x0 Pushing buttons 0-5 sets output pins to Pi. #define BUTTON_1 0xa55ae21d //0x10 0x800f #define BUTTON_2 0xa55aa15e //0x810 0x4007 #define BUTTON_3 0xa55a32cd //0x410 0xc00b #define BUTTON_4 0xa55af00f //0xc10 0x2003 #define BUTTON_5 0xa55ab04f //0x210 0xa00d #define BUTTON_6 0xa55a30cf //0xa10 0x6005 #define BUTTON_7 0xa55ab24d //0x610 0xe009 #define BUTTON_8 0xa55a8877 //0xe10 0x1001 #define BUTTON_9 0xa55a708f //0x110 0x900e void loop() { //Continue looping until you get a complete signal received if (myReceiver.getResults()) { if(myDecoder.decode()){ switch(myDecoder.value){ case BUTTON_0: pos=0; digitalWrite(led0,HIGH);break; case BUTTON_1: pos=1; digitalWrite(led1,HIGH);break; case BUTTON_2: pos=2; digitalWrite(led2,HIGH);break; case BUTTON_3: pos=3; digitalWrite(led3,HIGH);break; case BUTTON_4: pos=4; digitalWrite(led4,HIGH);break; case BUTTON_5: pos=5; digitalWrite(led5,HIGH);break; case BUTTON_6: pos=6; digitalWrite(led6,HIGH);break; case BUTTON_7: pos=7; digitalWrite(led7,HIGH);break; case BUTTON_8: pos=8; digitalWrite(led8,HIGH);break; case BUTTON_9: pos=9; digitalWrite(led9,HIGH);break; default: printf("Not in the number range");break; } Serial.println(pos); digitalWrite(toggle,LOW); //A falling toggle activates the Pi interrupt delay(200); //to check which led output was activated digitalWrite(toggle,HIGH); delay(700); //Time for the Pi to check on the led pin status digitalWrite(led0,LOW); //Whatever led was on, turn it off, Pi should digitalWrite(led0,LOW); //have finished reading the pins digitalWrite(led1,LOW); digitalWrite(led2,LOW); digitalWrite(led3,LOW); digitalWrite(led4,LOW); digitalWrite(led5,LOW); digitalWrite(led6,LOW); digitalWrite(led7,LOW); digitalWrite(led8,LOW); digitalWrite(led9,LOW); } myReceiver.enableIRIn(); //Restart receiver } }