/*
Copyright (c) 2014-2015 NicoHood
See the readme for credit to other people.
IRL Receive
Receives IR signals from different protocols and prints them to the Serial monitor.
Choose your protocols that should be decoded. Remove the not used ones to save flash/ram/speed.
You can choose a custom debounce time to not trigger a button two times in a row too fast.
The following pins are usable for PinInterrupt or PinChangeInterrupt*:
Arduino Uno/Nano/Mini: All pins are usable
Arduino Mega: 10, 11, 12, 13, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64),
A11 (65), A12 (66), A13 (67), A14 (68), A15 (69)
Arduino Leonardo/Micro: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI)
HoodLoader2: All (broken out 1-7) pins are usable
Attiny 24/44/84: All pins are usable
Attiny 25/45/85: All pins are usable
Attiny 13: All pins are usable
Attiny 441/841: All pins are usable
ATmega644P/ATmega1284P: All pins are usable
PinChangeInterrupts* requires a special library which can be downloaded here:
https://github.com/NicoHood/PinChangeInterrupt
*/
// include PinChangeInterrupt library* BEFORE IRLremote to acces more pins if needed
//#include "PinChangeInterrupt.h"
#include "IRLremote.h"
// Choose a valid PinInterrupt or PinChangeInterrupt* pin of your Arduino board
#define pinIR 2
// Choose the IR protocol of your remote. See the other example for this.
CNec IRLremote;
//CPanasonic IRLremote;
//CHashIR IRLremote;
//#define IRLremote Sony12
#define pinLed LED_BUILTIN
void setup()
{
// Start serial debug output
while (!Serial);
Serial.begin(9600);
Serial.println("Startup");
// Set LED to output
pinMode(pinLed, OUTPUT);
// Start reading the remote. PinInterrupt or PinChangeInterrupt* will automatically be selected
if (!IRLremote.begin(pinIR))
Serial.println(F("You did not choose a valid pin."));
}
void loop()
{
// Check if we are currently receiving data
//if (!IRLremote.receiving()) {
// Run code that disables interrupts, such as some led strips
//}
// Check if new IR protocol data is available
if (IRLremote.available()) //if it receive a code
{
// Get the new data from the remote
auto data = IRLremote.read(); //this gets the code that was sent
// Print the protocol data
Serial.println(data.command); //prints the code of the button that was pressed (data.command is the code received)
if(data.command == 25) // the code 25 is for the key EQ
{
Serial.println("I...AM STEEEEVE"); //do whatever you want when the button is pressed
}
}
}