I am creating an IR remote. So far I managed to write the code for the transmitter.
It works fine. It is on the latest library.
My IR Receiver code is on 2.6.0 library. It works fine. I can catch the NEC codes.
For example my power off code is 0x20DF10EF.
But when it is rewritten in the latest 4.7.1 version.
I seem to get false codes like 0xF708FB04.
Here is the code in version 2.6.0
#include <IRremote.h>
const int RECV_PIN = 11; // TSOP34838 OUT pin to Arduino D11
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
Serial.println("Ready to receive...");
}
void loop() {
if (irrecv.decode(&results)) {
if (results.value != 0xFFFFFFFF) { // Ignore repeat code
Serial.print("Code received: 0x");
Serial.println(results.value, HEX);
}
irrecv.resume(); // Receive the next code
}
}
and here is the new version 4.7.1:
#include <IRremote.h>
#define USE_IRREMOTE_HPP_AS_PLAIN_INCLUDE
const byte IR_RECEIVE_PIN = 11;
void setup()
{
Serial.begin(115200);
Serial.println("IR Receive test");
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK);
}
void loop()
{
if (IrReceiver.decode())
{
auto myRawdata= IrReceiver.printIRResultShort(&Serial);
Serial.println(myRawdata);
delay(100); // wait a bit
IrReceiver.resume();
}
}
I don't know why I am receiving two different codes.
I want to merge the receiver and transmitter code later.
The Arduino processor is ATmega168
That is why I am bothering at all.
I would be thankful if anybody can help.