BITD I wrote quite a few sketches using old tv remotes, checking the outputs from them and writing programs to receive signals from them and trigger outputs.
I have tried to get back to it with the up to date version of the irremote library but kept getting the offer to load the IR library 2.6.0 which I finally have done. I can now receive signals using irrecvDemo.ino from the examples.
/*
* IRremote: IRrecvDemo - demonstrates receiving IR codes with IRrecv
* An IR detector/demodulator must be connected to the input RECV_PIN.
* Version 0.1 July, 2009
* Copyright 2009 Ken Shirriff
* http://arcfn.com
*/
#include <IRremote.h>
#if defined(ESP32)
int IR_RECEIVE_PIN = 15;
#else
int IR_RECEIVE_PIN = 5;
#endif
IRrecv irrecv(IR_RECEIVE_PIN);
decode_results results;
// On the Zero and others we switch explicitly to SerialUSB
#if defined(ARDUINO_ARCH_SAMD)
#define Serial SerialUSB
#endif
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
#if defined(__AVR_ATmega32U4__)
while (!Serial)
; //delay for Leonardo, but this loops forever for Maple Serial
#endif
#if defined(SERIAL_USB) || defined(SERIAL_PORT_USBVIRTUAL)
delay(2000); // To be able to connect Serial monitor after reset and before first printout
#endif
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__));
// In case the interrupt driver crashes on setup, give a clue
// to the user what's going on.
Serial.println("Enabling IRin");
irrecv.enableIRIn(); // Start the receiver
Serial.print(F("Ready to receive IR signals at pin "));
Serial.println(IR_RECEIVE_PIN);
}
void loop() {
if (irrecv.decode(&results))
{
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
if ((irrecv.decode(&results) == 4FB9867))
{
Serial.println("well done")
}
delay(100);
}
running it I get a number 4FB9867 when I press a key on my remote so I have added a few lines to try to add a new ‘if’ command that just gives me an indication if it sees the button pressed but I can’t find the correct format for the command.
Am I in the right area and can you tell me what the correct command is or am I unable to read the incoming button press in this way?