IR remote code malfunctioning

Hello!
I'm a beginner. I don't know much when it comes to libraries/updates etc.
So my code was working as intended a couple of weeks back. Today I uploaded it back to my Arduino and it's not working as intended. I suspected that I may have updated my libraries which caused the issue but the issue remained even tho I deleted the new update.
The code is supposed to work like this:
I press 1 "0xFF30CF" on my remote--> "EQ led pin 2" Lights up and it waits for my input on the remote using a while loop
The problem is it only goes through the while loop once and then it just gets stuck i know that because it only prints "Waiting for input, press EQ to go back." one time(without my input).

type or paste code here
  if (cmd.value == 0xFF30CF) {

    while (inputled1 == false) {
      while (IR.decode(&cmd) == 0) {
// It Gets stuck here it does not detect ir signals
      }
      IR.decode(&cmd);
      Serial.println("");
      Serial.println("Waiting for input, press EQ to go back.");
      if (cmd.value == 0xFFE01F) {
        myComred = "vol-";
        redbrightness = redbrightness - 51;
        Serial.println(myComred);
        //Serial.println("");
        Serial.print("Volume : ");
        //Serial.println("");
      }
      if (cmd.value == 0xFFA857) {
        myComred = "vol+";
        redbrightness = redbrightness + 51;
        Serial.println(myComred);
        //Serial.println("");
        Serial.print("Volume : ");
        //Serial.println("");
      }
      if (cmd.value == 0xFF906F) {
        myComred = "EQ";
        inputled1 = true;
        Serial.println(myComred);

      }
      if (cmd.value == 0xFF629D) {
        myComred = "pwr";
        if (redbrightness > 0) {
          redbrightness = 0;
          ledison = false;
          Serial.println("powered off.");
        }
        else {
          redbrightness = 255;
          ledison == true;
          Serial.println("powered on.");
        }
        //Serial.println(myComred);
      }
      //Serial.println(cmd.value, HEX);
      delay(50);
      IR.resume();
      if (redbrightness > 255) redbrightness = 255;
      if (redbrightness < 0) redbrightness = 0;
      analogWrite(redled, redbrightness);
      Serial.print(redbrightness);
      delay(100);
      digitalWrite(EQled, HIGH);

    }
    digitalWrite(EQled, LOW);
    delay(100);
    Serial.println(cmd.value, HEX);
    Serial.println("out");
    IR.resume();

  }
inputled1 = false;

Thanks

Please post your full code. Which IR library are you using? Which version?

1 Like

why do you check the cmd value before conditionally calling IR.decode()?

why do you check inputled1 before conditionally calling IR.decode()?

there's no reason to what for input by remaining in a while loop if IR.decode() returns zero. just check if there is input each time loop() is called


void
loop (void)
{
    if (IR.decode (&cmd)) {
        if (cmd.value == 0xFF30CF) {
            ...
        }

        ...

        IR.resume ();
    }
}
1 Like

@gcjr @sterretje
Thanks For your replies, I didn't post the full code previously because it is too long and lacks comments.
Apparently, this issue got nothing to do with libraries.
I used the same code on an online Arduino simulator(Login | Tinkercad) and it worked perfectly.
Can this be an issue with the Arduino bootloader or is it a hardware issue?

Answering that question obviously requires more information from you.

1 Like

I'm not sure which information I did not provide.
I've tried multiple codes with the Arduino and they do not work while working on online compilers.
My question is general: is there a way I can know if it is a hardware/software issue?

Not sure what was the issue. It just started working again without any modifications.

Yes, the way is to look at all the code and all the hardware.

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