IR receiver not working

Hello!
I need IR receiver for my project. I connected everything correct (I watched tutorials). I copied a code. When I uploaded the code there was no errors. I plugged my arduino nano to my pc and opened the serial monitor. Then I clicked some buttons on my ir remote but it didn't show anything.
Here is the code:

#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
  }
}

I would really appreciate your help. :grinning_face:

show us a picture of your circuit

(have you tried one of the built in example that comes with the library like Arduino-IRremote/examples/SimpleReceiver/SimpleReceiver.ino at master · Arduino-IRremote/Arduino-IRremote · GitHub ?)

also make sure your Serial monitor is set at 9600 bauds, matching

Did you study the documentation for IRremote.h before you wrote the code?

No errors perhaps, but a boatload of warnings with the compiler warning level set to ALL.

arduino-cli compile -b arduino:avr:nano:cpu=atmega328 --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Nano/test)

In file included from /home/me/Documents/sketchbook/Nano/test/test.ino:1:0:
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:12:2: warning: #warning Thank you for using the IRremote library! [-Wcpp]
 #warning Thank you for using the IRremote library!
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:13:2: warning: #warning It seems, that you are using a old version 2.0 code / example. [-Wcpp]
 #warning It seems, that you are using a old version 2.0 code / example.
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:14:2: warning: #warning This version is no longer supported! [-Wcpp]
 #warning This version is no longer supported!
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:15:2: warning: #warning Please use one of the new code examples from the library available at "File > Examples > Examples from Custom Libraries / IRremote". [-Wcpp]
 #warning Please use one of the new code examples from the library  available at "File > Examples > Examples from Custom Libraries / IRremote".
  ^~~~~~~
In file included from /home/me/Documents/sketchbook/Nano/test/test.ino:1:0:
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:16:2: warning: #warning Or downgrade your library to version 2.6.0. [-Wcpp]
 #warning Or downgrade your library to version 2.6.0.
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:17:2: warning: #warning Start with the SimpleReceiver or SimpleSender example. [-Wcpp]
 #warning Start with the SimpleReceiver or SimpleSender example.
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:18:2: warning: #warning The examples are documented here: https: [-Wcpp]
 #warning The examples are documented here: https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:19:2: warning: #warning A guide how to convert your 2.0 program is here: https: [-Wcpp]
 #warning A guide how to convert your 2.0 program is here: https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version
  ^~~~~~~
/home/me/Documents/sketchbook/Nano/test/test.ino:5:23: warning: 'IRrecv::IRrecv(uint_fast8_t)' is deprecated: Please use the default IRrecv instance "IrReceiver" and IrReceiver.begin(), and not your own IRrecv instance. [-Wdeprecated-declarations]
 IRrecv irrecv(RECV_PIN);
                       ^
In file included from /home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.hpp:286:0,
                 from /home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:10,
                 from /home/me/Documents/sketchbook/Nano/test/test.ino:1:
/home/me/Documents/sketchbook/libraries/IRremote/src/IRReceive.hpp:79:1: note: declared here
 IRrecv::IRrecv(uint_fast8_t aReceivePin) {
 ^~~~~~
/home/me/Documents/sketchbook/Nano/test/test.ino: In function 'void loop()':
/home/me/Documents/sketchbook/Nano/test/test.ino:16:29: warning: 'bool IRrecv::decode(decode_results*)' is deprecated: Please use IrReceiver.decode() without a parameter and IrReceiver.decodedIRData.<fieldname> . [-Wdeprecated-declarations]
   if (irrecv.decode(&results))  {
                             ^
In file included from /home/me/Documents/sketchbook/Nano/test/test.ino:1:0:
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:29:6: note: declared here
 bool IRrecv::decode(decode_results *aResults) {
      ^~~~~~
Sketch uses 5882 bytes (19%) of program storage space. Maximum is 30720 bytes.
Global variables use 544 bytes (26%) of dynamic memory, leaving 1504 bytes for local variables. Maximum is 2048 bytes.
Compilation finished successfully.

I couldn't make better photo.

  • We should probably check you wiring :thinking:
  • Add some simple serial monitor code to confirm you can print to it.

  • Schematic diagrams are the universal language of electronics.

  • We use schematics to communicate hardware design. All components and connections are illustrated.

  • As always, show us a good schematic of your proposed circuit. Hand drawn schematics are acceptable.

  • Show us several good image views of your actual wiring.

  • Give WEB links to your major components.




  • Always blame yourself first ;)

I made it!

When I opened serial monitor it said to update the library and I just needed to add new code and now I can see the signals.
Thank you, @LarryD for the help!

What version of IDE and IRremote.h library are you using?

I assembled your project here using IDE 1.8.9 and library 4.3.2, and the following message was printed:

Pay particular attention to the phrase:

It seems, that you are using a old version 2.0 code / example.

“


Thank you for using the IRremote library!
It seems, that you are using a old version 2.0 code / example.
This version is no longer supported!
Please use one of the new code examples from the library,
available at "File > Examples > Examples from Custom Libraries / IRremote".
Or downgrade your library to version 2.6.0.

Start with the SimpleReceiver or SimpleSender example.

The examples are documented here:

A guide how to convert your 2.0 program is here:

Thanks


I already made it and it solved my problem.
I appreciate your work!