/*************************************************** A simple example on how to use the IR library ****************************************************/ #include #include #include #include #define IR_RECV_PIN 12 // GPIO12 #define IR_SEND_PIN 5 // GPIO5 namespace { SimpleTimer irTimer; IRrecv irrecv(IR_RECV_PIN); IRsend irsend(IR_SEND_PIN); void receiveIR() { decode_results dresults; dresults.decode_type = UNUSED; if(irrecv.decode(&dresults)) { Serial.println(resultToHumanReadableBasic(&dresults)); // Output the results as source code Serial.println(resultToTimingInfo(&dresults)); irrecv.resume(); } if(dresults.decode_type > UNUSED) { Serial.println("Send IR Code"); irsend.send(dresults.decode_type, dresults.value, dresults.bits); } irTimer.startOnce(); } } // namespace void init() { Serial.begin(SERIAL_BAUD_RATE); // 115200 by default Serial.println("Setting up..."); irrecv.enableIRIn(); // Start the receiver irTimer.initializeMs<200>(receiveIR).startOnce(); Serial.println("Ready..."); }