IR remote LED light error

Hello, everyone.
I would be very grateful if you could help me with this matter. I am a complete beginner and I'm just working through some tutorials. I suffered error "The function decode(&results)) is deprecated and may not work as expected! Just use decode() - without any parameter.". So I write code with reference to new version. Error is gone, but still LED light doesn't turn up. What should I do? I have no idea. Serial monitor prints
0
F30CBF00
Thanks.

#include <IRremote.h>

const byte RECV_PIN = 8;


void setup(){
 pinMode(9,OUTPUT);
 Serial.begin(9600);
  IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK);
 
}

void loop(){
  if(IrReceiver.decode()) {
    Serial.println(IrReceiver.decodedIRData.decodedRawData,HEX); 
    if(IrReceiver.decodedIRData.decodedRawData == 0xFD30CF) {
      digitalWrite(9,HIGH);
    }
    else{
      digitalWrite(9,LOW);
    }
    delay(500);
    IrReceiver.resume(); 
  }
}

The led should light if the above code is received. You do not appear to be transmitting such a code. Instead, it looks like you are sending F30CBF00

How can I send 0xFD30CF code? And why my code send F30CBF00? I change code
int F30CBF00 = 0; if(IrReceiver.decodedIRData.decodedRawData == F30CBF00) {
Then led light when push every remote button. But I want to turn on led only when I push 0 button.

If you are still seeing "F30CBF00" on the serial monitor, then, in the original code you posted, change this line:
if(IrReceiver.decodedIRData.decodedRawData == 0xFD30CF) {
to
if(IrReceiver.decodedIRData.decodedRawData == 0xF30CBF00) {
to see if it now behaves as you want.
If you still have difficulties, post the amended code and the results you see on the serial console.
State also what remote control device you are using to test it with.

1 Like

WoW!!! Now It's working!!! Thank you so much.

The old version of the library read the signal backwards: the remote sends LSB first, but the library interpreted it MSB first.

Then should I change library?

You Should Update

As per post #4 your issue is resolved.

@mito_y are you able to get the code correctly or not

I use Tinkercad for using Arduino so I can't update it.
And now my code is here.

#include <IRremote.h>

// C++ code
//
const byte RECV_PIN = 8; 


void setup(){
 pinMode(9,OUTPUT);
 Serial.begin(9600);
  IrReceiver.begin(RECV_PIN, ENABLE_LED_FEEDBACK); 
 
}

void loop(){
  if(IrReceiver.decode()) { 
    Serial.println(IrReceiver.decodedIRData.decodedRawData,HEX); 
    if(IrReceiver.decodedIRData.decodedRawData == 0xF30CBF00) {
      digitalWrite(9,HIGH);
    }
    else{
      digitalWrite(9,LOW);
    }
    delay(30);
    IrReceiver.resume(); 
  }
}

If you are using Tinkercard no issue is there but first check the HEX code of the remote

If I push 0 button three times serial monitor prints
F30CBF00
0
F30CBF00
If I push 1,
EF10BF00
0
EF10BF00
If I push 2,
EE11BF00
0
EE11BF00
If I push 3,
ED12BF00
ED12BF00
ED12BF00
If I push 4,
EB14BF00
EB14BF00
0
If I push 5,
EA15BF00
EA15BF00
EA15BF00
If I push 6,
E916BF00
E916BF00
E916BF00
If I push 7,
E718BF00
E718BF00
E718BF00
If I push 8,
E718BF00
E718BF00
E718BF00
If I push 9,
E51ABF00
E51ABF00
E51ABF00.
I think they are not HEX code because 0's HEX code is 0xFD30CF.

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