IR Receiver problem

Hi there im getting problems when trying to check each code of each button on my IR remote.

everytime I try a button I only get "FFFFFFFF" on the Serial Monitor

This is the code

#include <IRremote.h>

int receptor = 24;
int led = 7;
IRrecv irrecv(receptor);
decode_results code;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
if(irrecv.decode(&code))
{
  Serial.println(code.value, HEX);

if (code.value==0xFF6897)
{
  digitalWrite(led,HIGH);
}
if (code.value==0xFF30CF)
{
  digitalWrite(led,LOW);
}

delay(500);
irrecv.resume();
}

}


1 Like

Always show us a good schematic of your proposed circuit.
Show us a good image of your ‘actual’ wiring.
Give links to components.

FFFFFFFF is probably a repeat code.

Welcome to the forum

If I recall correctly, 0xFFFFFFFF is often used as the repeat code that is sent when a key on the remote is held down. Are you sure that the initial code received is not just scrolling up the screen ?

As a quick and dirty test try adding a delay(500) immediately after printing the received code

Where did you get the values that you are testing for ?

Hi there, from the Serial Monitor,

Please take a look at the attached image

These are the images of my wiring:

I used pin 24

Black: Ground
White: Power
Gray: Pin


I see it. Did you see reply #2 and #3? They are both already explaining the data in the image...

But I'm not holding any button, I just press them and keep getting this

I added the delay just after the println but didn't solve it

#include <IRremote.h>

int receptor = 24;
int led = 7;
IRrecv irrecv(receptor);
decode_results code;


void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
irrecv.enableIRIn();
pinMode(led, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
if(irrecv.decode(&code))
{
  Serial.println(code.value, HEX);
delay(500);
if (code.value==0xFF6897)
{
  digitalWrite(led,HIGH);
}
if (code.value==0xFF30CF)
{
  digitalWrite(led,LOW);
}

delay(500);
irrecv.resume();
}

}

As requested, where did you get these numbers from ?


Make sure your IR receiver is the same wavelength as the remote control.

I googled 0 and 1 codes and see if it worked.

But since it wasnt doing anything I tried to check each code for each key but only got FFFFFF

Forget all that. There is a discovery sketch that comes with the IR library, designed to identify the protocol. It should be able to decode and give you the correct codes for your remote.

Once you have those, you can re-write your sketch to use the working codes.

Really?

And how can I do that? haha

I want to get the correct codes from my buttons '1' and '2' to use them to open/close a door with a servo (check code)

 // Check if IR signal is received
  if (irrecv.decode(&results)) {
    switch (results.value) {
      case 0xC: // IR code for button 1
        doorServo.write(doorOpenAngle);
        digitalWrite(yellowLedPin, HIGH);
        lcd.clear();
        lcd.print("Door is open");
        doorIsOpen = true;
        break;
      case 0x18: // IR code for button 2
        doorServo.write(doorCloseAngle);
        digitalWrite(yellowLedPin, LOW);
        lcd.clear();
        lcd.print("Door is closed");
        doorIsOpen = false;
        break;
    }
    irrecv.resume(); // Receive the next value
  }
}

But I don't know how to get the correct HEX code to be able to use the remote. Funny enough If I plug the IR receiver to where I coded a pushbutton it kinda works but with every key that I press.

Hi,
Can you please post a link to data/spec of the IR receiver?

It looks like an IR detector, but not a proper 38khz IR remote reciever.

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

As mentioned, look at the libraries’s example sketches(s) .

The sketch will print the received button code.

I'm using the Elegoo remote control with the IR receiver that came with it.

I'm also using a Mega2560 board.

I told you how to do it. Welcome to my permanent ignore list.

Those are NEC.

Hi,

Okay, angle of photo doesn't show the grill in front to the sensor.
Can you post connection diagram with pin names, that receiver PCB looks like it is repurposed from another component module.

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

Really friendly community I see.

Thanks anyway

What version of the IRremote library do you have installed. The posted code is for an older version (< 3.0) of the library and may not work right with the newer library versions.

The latest one, 4.1.3