////////////////////////////////////////////////////////////////////////////////
// Name: KY-022 //
// IR remote control receiver //
// Platform: Arduino Mega 2560 //
// Created by: HARB rboek2@gmail.com Feb 2020 GPL copyrights //
// http://robotigs.com/robotigs/includes/parts_header.php?idpart=10 //
// The S-pin must be connected to an interrupt input. //
// This program show a pressed key from IR remote control on serial monitor. //
// Do not forget to replace the original library. //
////////////////////////////////////////////////////////////////////////////////
/* A simple example, using the IRsmallDecoder library,
* for testing remote controls that use the NEC protocol.
*
* Note: for the NEC extended protocol, just define IR_SMALLD_NECx instead of IR_SMALLD_NEC
*
* In this example it's assumed that the IR sensor is connected to digital pin 2 and
* the pin is usable for external interrupts.
* For more information on the boards' usable pins, see the library documentation at:
* https://github.com/LuisMiCa/IRsmallDecoder
* or the README.pdf file in the extras folder of this library.
*/
//#define IR_SMALLD_NEC
//#define IR_SMALLD_NECx
//#define IR_SMALLD_RC5
//#define IR_SMALLD_SAMSUNG
//#define IR_SMALLD_SIRC12 COMPILEERT ZELFS NIET
//#define IR_SMALLD_SIRC
//#define IR_SMALLD_SAMSUNG
//#define IR_SMALLD_SAMSUNG32
#define IR_SMALLD_RC5 //1st: define which protocol to use and then,
#include <IRsmallDecoder.h> //2nd: include the library;
IRsmallDecoder irDecoder(2); //3rd: create one decoder object with the correct digital pin;
irSmallD_t irData; //4th: declare one decoder data structure;
void setup() {
Serial.begin(57600);
Serial.println("Waiting for a NEC remote control IR signal...");
Serial.println("held\t addr\t cmd");
}
void loop() {
if(irDecoder.dataAvailable(irData)) { //5th: if the decoder has some new data available,
Serial.print(irData.keyHeld,HEX); //6th: do something with the data.
Serial.print("\t ");
Serial.print(irData.addr,HEX);
Serial.print("\t ");
Serial.println(irData.cmd,HEX);
}
}