I downloaded the latest version of IRemote and successfully included the library, It is the latest version too. I am using an elegoo with a ir sensor and a remote. I compile this code in my ide next.
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}
void loop() {
if (irrecv.decode(&results)) {
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
delay(100);
}
It is connected to my computer and running properly I see a little red dot blink on the ir receiver when i click a button on the remote but I get the following error.
The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter.
I don't know any other way to do what I am doing while just using decode(). I cannot see how that's possible. I hope someone has some advice for me thanks alot.
You can either change your code to work with the new version of the library, following the instructions that gfvalvo pointed out or you can delete the new version of the IRremote library from your sketchbook/libraries folder and install an older version (2.x.x) and keep the code the way that it is. The older versions are available for install from the IDE library manager.
Hello. I have gone into the code examples for the latest version and compiled and ran the simple receiver demo. It worked but when I press a button It displays funny characters that I do not recognize like this ⸮⸮[ћN⸮6
The following is the code
/*
* SimpleReceiver.cpp
*
* Demonstrates receiving NEC IR codes with IRrecv
*
* Copyright (C) 2020-2021 Armin Joachimsmeyer
* armin.joachimsmeyer@gmail.com
*
* This file is part of Arduino-IRremote https://github.com/Arduino-IRremote/Arduino-IRremote.
*
* MIT License
*/
/*
* Specify which protocol(s) should be used for decoding.
* If no protocol is defined, all protocols are active.
*/
//#define DECODE_DENON
//#define DECODE_SHARP // the same as DECODE_DENON
//#define DECODE_JVC
//#define DECODE_KASEIKYO
//#define DECODE_PANASONIC // the same as DECODE_KASEIKYO
//#define DECODE_LG
#define DECODE_NEC
//#define DECODE_SAMSUNG
//#define DECODE_SONY
//#define DECODE_RC5
//#define DECODE_RC6
//#define DECODE_BOSEWAVE
//#define DECODE_LEGO_PF
//#define DECODE_MAGIQUEST
//#define DECODE_WHYNTER
//#define DECODE_HASH // special decoder for all protocols
#include <Arduino.h>
/*
* Define macros for input and output pin etc.
*/
#include "PinDefinitionsAndMore.h"
#include <IRremote.h>
void setup() {
Serial.begin(115200);
// Just to know which program is running on my Arduino
Serial.println(F("START " __FILE__ " from " __DATE__ "\r\nUsing library version " VERSION_IRREMOTE));
/*
* Start the receiver, enable feedback LED and take LED feedback pin from the internal boards definition
*/
IrReceiver.begin(IR_RECEIVE_PIN, ENABLE_LED_FEEDBACK, USE_DEFAULT_FEEDBACK_LED_PIN);
Serial.print(F("Ready to receive IR signals at pin "));
Serial.println(IR_RECEIVE_PIN);
}
void loop() {
/*
* Check if received data is available and if yes, try to decode it.
* Decoded result is in the IrReceiver.decodedIRData structure.
*
* 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
IrReceiver.printIRResultShort(&Serial);
if (IrReceiver.decodedIRData.protocol == UNKNOWN) {
// We have an unknown protocol here, print more info
IrReceiver.printIRResultRawFormatted(&Serial, true);
}
Serial.println();
/*
* !!!Important!!! Enable receiving of the next value,
* since receiving has stopped after the end of the current received data packet.
*/
IrReceiver.resume(); // Enable receiving of the next value
/*
* Finally, check the received data and perform actions according to the received command
*/
if (IrReceiver.decodedIRData.command == 0x10) {
// do something
} else if (IrReceiver.decodedIRData.command == 0x11) {
// do something else
}
}
}
The following is the output on the console.
START C:\Use
examples\SimpleReceiver\SimpleReceiver.ino from Mar 19 2021
Using library version 3.1.0
Ready to receive IR signals at pin 2
⸮⸮[ћN⸮6B⸮⸮x⸮].,⸮<⸮⸮⸮b!⸮⸮U⸮⸮⸮⸮⸮d,⸮<⸮⸮ ⸮U@a⸮⸮4⸮e&WI⸮⸮d⸮1⸮t⸮9#WI⸮t⸮e&⸮%⸮e⸮⸮⸮_.⸮h⸮T⸮9cta⸮⸮d`⸮⸮⸮d⸮⸮⸮<4⸮⸮&W ⸮