I would be most grateful for any help. I am a complete beginner and I'm just working through some tutorials. I have installed the IRremote library and have loaded some example codes (therefore the coding must be correct?), and my remote isn't working, instead returning this error code in my serial monitor;
"The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter."
Any ideas? It's so frustrating.
Thanks,
Andy
#include <IRremote.h>
int RECV_PIN = 11; // define input pin on ArduinoÂ
IRrecv irrecv(RECV_PIN);Â
decode_results results; // decode_results class is defined in IRremote.h
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); // small delay to prevent reading errors
}
I just ran into that myself. That error is the result of running code written with the old IRRemote library. The new version of the library has made significant changes. There are several examples to help learn the new version.
Here is the code written with the newer library that does the kind of the same as your posted code.
#include <IRremote.h>
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())
 {
   Serial.println(IrReceiver.decodedIRData.command, HEX);
   IrReceiver.resume();
 }
}
This is actually kind of a bummer cause I have a lot of code written for the old library.
You have 2 choices. Learn the new library or roll back to (install) a previous version. Previous versions are available through the library manager.
That certain explains a lot, but regretfully I'm still having trouble. I have tired the code you kindly provided and it just returns the following error message on compiling; "'IrReceiver' was not declared in this scope"
I have tried rolling back to an older library to use the previous code as you suggested, and it provides hex values which vary for each number (for example number 4 on my keypad is 4CB0FADC and then D52A1FEA). Is this right, and if so then how can I assign a value to a hex if it changes each time the button is pressed?
Did you copy my code exactly? I know that it works because I tested it with an IR decoder and my Uno. The code that I posted uses the newest version of IRRemote library.
Post the code that you can that generated the error and the complete text of the error message.
With that code, my remote (NEC) gives a 1, 2 or 3 digit number unique and repeatable for each key.
I also have the newest IRremote library installed, 3.0.1.
I made a simple circuit, powering the receiver board, then running a signal wire to pin 11.
I found a tutorial that said that setup should work to get data to the signal monitor when the remote buttons were pushed, but using the code from post #2, I am not seeing anything. However, that tutorial was done using the old libraries, so, not sure if that makes a difference? Or is that not the right circuit to use at all?
I also tried the SimpleReceiver.ino example from the library on this circuit, and did not see anything on the signal monitor either. I did confirm the remote works using the camera cellphone thing.
I guess I just need to know if this IR receiver I got is functional at all, and if there is any other way to test it. This is the first time we have tried using it. One thing I noticed is the IR receiver has an LED on its board, but it does not light up when the sketch is uploaded. Is it supposed to?
When you ran the code in reply #2 you should have seen, at least, "IR Receive test" even if the receiver is not working. If not, check that the baud rate in serial monitor is set to 115200.
Does the built in LED (L) on your Arduino board light when you press a button on the remote?
Here are the pics. Brown wire to pin 11. Red to 5v on uno. Black to gnd on uno. Also a closeup of the receiver. Looks just like the Keyes you see online but doesn’t have that name on it.
I do see the “receive test” response from the code in the monitor, so the uno is def getting the code uploaded at the correct baud rate. But no leds respond either on the uno or the receiver board when buttons pressed.
EDIT:
Forum is not liking my iPhone pics, I'll have to convert. Hang on
I have tried rolling back to an older library to use the previous code as you suggested, and it provides hex values which vary for each number (for example number 4 on my keypad is 4CB0FADC and then D52A1FEA). Is this right, and if so then how can I assign a value to a hex if it changes each time the button is pressed?
Is this the only 2 numbers you get? If so, then just check for both as valid!
johns786, can you confirm that your remote is sending. Many cell phone cameras are sensitive to IR so you should be able to see the IR LED flash in the camera as you press buttons on it.
groundFungus:
johns786, can you confirm that your remote is sending. Many cell phone cameras are sensitive to IR so you should be able to see the IR LED flash in the camera as you press buttons on it.
Yes, I can see the blinking if I use a phone camera.
I also turned off all the lights in the room to make sure there wasn't any background noise.
I added a pic of the wiring to my earlier post--I don't know why my iphone .jpg wasn't working, so had to use a .pdf
The IR_RECEIVE_PIN can be any digital pin. Does not have to be an interrupt. The code in reply #2 uses pin 11 (Uno) and works. The older versions of IRRemote had to use only pin 3 for transmit. I have not looked into the send part of the library to see if there are changes to that part.
Yeah, I had tested all the other pins earlier, changing the code, just in case it was that. It didn’t make a difference.
I’m just going to order new hardware, these sensors are pretty cheap. I’m going to get a stand-alone sender and receiver diode too, it’ll make it easier to troubleshoot if I can have the components individually instead of on a board
Many thanks for the replies. As the original poster, I hope I can steer things back to the issue I was struggling with which has been diverted since John entered the thread. I don't mean to be rude to John but maybe it would be less confusing for those helping if he started his own thread with the issues he is facing?
Thanks to groundFungus' replies, the code is compiling and I have now changed the serial monitor to 115200 baud, which is now giving me the "IR Receive test" line, however when a button is pressed it returns the value "0". I would be grateful if you have any ideas as to why this might be as you've been very helpful so far.
Andy,
Just wrote an awesome reply that the forum sent off into oblivion. So, I'll try again. Apologies if this becomes too cryptic due to my now miffed attitude-its not aimed at you....
I too have been struggling with zeros for a couple of days. Any chance you are using an Elegoo kit? The answer is...change remotes. Apparently there is nothing magic about the receiver/remote pair. I have now tried 5 different "credit card" remotes and a TV remote and all but one work fine. The Elegoo remote-nada. Each key gives me a unique/repeatable code. I always seem to get two lines of output, a "key down" and "key up" I expect. Hopefully I can use this link to solve this: LINK
He/she still uses the old IRremote code, but I found the explanations very good.
Really grateful for the helpful reply, especially given your problem first time round.
You are entirely correct, I have been using an Elegoo remote, so that explains a lot. I'm just reading the article you kindly provided and it's very helpful.