IR sensor spitting out multiple different codes for the same button, and occasional 0's?

So, I'm learning how to use arduino and following guides after buying the elegoo 'super starter kit'.

this is the code I'm using;

#include <IRremote.h>

const int RECV_PIN = 2;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn();
}

void loop()
{
if (irrecv.decode(&results))
{
int value = results.value;
Serial.println(" ");
Serial.print("Code: ");
Serial.println(results.value); //prints the value a a button press
Serial.println(" ");
irrecv.resume(); // Receive the next value
Serial.println("*****************");
}
}

and yet, something seems incredibly off. I've tried multiple different IR remotes to decode to test if it was an issue with the remote I was given or what; they all do the same thing when I bring up the serial monitor.

here are some of the IR codes it's spit out, for example.

Code: 404189791


Code: 404189791


Code: 99832004


Code: 404189791


Code: 404189791


Code: 1536257714


Code: 404189791


Code: 2532405468


Code: 0


Code: 0


Code: 0


Code: 4239130559


Code: 0


Code: 1456440334


Code: 3677042839


Code: 155650165

this is all from the same button on the remote. every button does more or less the same thing(but with different codes), and other remotes I have around the same also do the same thing.

FWIW, the IR sensor is plugged into the 3.3v rather than the 5v that the instructions told me, but when I put it in the 5v, the IR receiver just doesn't work at all anyway. I can't figure out whats going on; issue with the code? the receiver? not compatible with the library I'm using?

You seem to have missed the update to the IRremote.h. Please study the updated documentation.

Paul

I wouldn't say I missed, I downloaded the latest library that's available through the arduino IDE, which is 3.3.

Hi, @kyris_gaming
Welcome to the forum.

To add code please click this link;

Can you post a copy of your circuit and a picture of your project?
So we can check your component layout.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Also post the part number of the IR receiver you are using and a link to the instructions you are following.
The 3.3volt / 5v story sounds strange and is likely to be a problem.

I asked because the documentation specifically says NOT to use the old methods you are using.
Paul

thats the best I can do, for the circuit. it seems like tinkercad uses IR receiver diodes only, while I'm using an IR breakout board that came with my starter kit, so my actual wiring is a tiny bit different.

as for the project; right now Its not being implemented into an actual project. I'm just using a breadboard to test code and learn how to use arduino - I'm extremely new at all of this.

there's a picture of the breadboard, though - ignore the LEDs, those were for testing another bit of code that I already got working.

So, that I actually figured out. there was a resistor mounted to the breadboard that was in series with the receiver that I didn't notice. My bad. 5v works fine now, but its still acting wonky and spitting out different codes.

that said, it is a 1838 breakout.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.