This code for IR sensor is bugging

Hello, I am new to Arduino and I need help fixing a project that uses a remote and an IR sensor to turn a servo in two different positions but the "if" statement seems to be completed every time.
please help fix the code, thank you. :slight_smile:

code

#include <IRremote.h> 
#include <Servo.h>

const int RECV_PIN = 7;
IRrecv irrecv(RECV_PIN);
decode_results results;
Servo ms;
void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn();
  irrecv.blink13(true);
  ms.attach(9);
}

void loop(){
  if (irrecv.decode(&results)){
   irrecv.resume();

        if ("FFA25D" == results.value, HEX){ // if button 1 is pushed
          Serial.println("1");
            ms.write(35);
            delay(1000);
        }

        if ("FFE21D" == results.value, HEX){
          ms.write(100); //if button 2 is pushed
          delay(1000);
          Serial.println("2");
        }
  }
}

Lose the ", HEX".
Report back.

Edit: does the library have any examples?
"decode_results" doesn't look like a String

i am no longer receiving an anser.
the library does not have any exemples.

Did you look at the README for the IRremote Library? That overload of the decode() function has been depricated.

The IRremote library has plenty of examples.

You can't compare a string literal to an unsigned long variable like that. Usually, you would compare two numbers:
if (0xFFE21D == results.value) {

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