/*
* Specify which protocol(s) should be used for decoding.
* If no protocol is defined, all protocols (except Bang&Olufsen) are active.
* This must be done before the #include <IRremote.hpp>
*/
//#define DECODE_BEO // This protocol must always be enabled manually, i.e. it is NOT enabled if no protocol is defined. It prevents decoding of SONY!
//#define DEBUG // Activate this for lots of lovely debug output from the decoders.
//#define RAW_BUFFER_LENGTH 180 // Default is 112 if DECODE_MAGIQUEST is enabled, otherwise 100.
#include <Arduino.h>
#include "PinDefinitionsAndMore.h" // This include pin number for IR_RECEIVE_PIN(2), IR_SEND_PIN(3)
#include <IRremote.hpp> // include the library
bool LOn9 = false;
bool LOn10 = false;
bool LOn11 = false;
bool LOn12 = false;
void setup() {
Serial.begin(9600);
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ ". Using library version " VERSION_IRREMOTE));
// Start the receiver and if not 3. parameter specified, take LED_BUILTIN pin from the internal boards definition as default feedback LED
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
// IrReceiver.begin(IR_RECEIVE_PIN);
Serial.print(F("Ready to receive IR signals of protocols: \r\n\t"));
printActiveIRProtocols(&Serial);
Serial.println(F("\r\n\tat pin " STR(IR_RECEIVE_PIN)));
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, OUTPUT);
}
void loop() {
/* E.g. command is in IrReceiver.decodedIRData.command
* address is in command is in IrReceiver.decodedIRData.address
* and up to 32 bit raw data in IrReceiver.decodedIRData.decodedRawData
*/
if (IrReceiver.decode()) {
// Print a short summary of received data
if (IrReceiver.decodedIRData.protocol != UNKNOWN) {
IrReceiver.printIRResultShort(&Serial);
// IrReceiver.printIRSendUsage(&Serial);
delay(300); // to work with any remote IR protocol .. more or less ... tested with arduino remote, tv remote andsome remote for electrical heating
Serial.println();
}
IrReceiver.resume(); // Enable receiving of the next value
unsigned long IRcmd = IrReceiver.decodedIRData.decodedRawData;
if (IRcmd == 0xF30CFF00 || IRcmd == 0xE401BF || IRcmd == 0x40D) {
LOn9 = !LOn9;
digitalWrite(9, LOn9 ? HIGH : LOW);
}
if (IRcmd == 0xE718FF00 || IRcmd == 0xE8017F || IRcmd == 0x4D) {
LOn10 = !LOn10;
digitalWrite(10, LOn10 ? HIGH : LOW);
}
if (IRcmd == 0xA15EFF00 || IRcmd == 0xD8027F || IRcmd == 0x8D) {
LOn11 = !LOn11;
digitalWrite(11, LOn11 ? HIGH : LOW);
}
if (IRcmd == 0xF708FF00 || IRcmd == 0xFF000F || IRcmd == 0x20D) {
LOn12 = !LOn12;
digitalWrite(12, LOn12 ? HIGH : LOW);
}
}
}