Problem with infrared remote control and lcd "invalid header file"

Continuing the discussion from Invalid Header File TinkerCad:

I have this same problem with infrared remote control and lcd

my code

#include <IRremote.h>
#include <Adafruit_LiquidCrystal.h>

Adafruit_LiquidCrystal lcd_1(0);

// Function prototype
int mapCodeToButton(unsigned long code);

int readInfrared() {
  int result = -1;
  if (IrReceiver.decode()) {
    unsigned long code = IrReceiver.decodedIRData.decodedRawData;
    result = mapCodeToButton(code);
    IrReceiver.resume();
  }
  return result;
}

// Actual implementation of mapCodeToButton
int mapCodeToButton(unsigned long code) {
  // Your implementation here
  // ...
  if ((code & 0x0000FFFF) == 0x0000BF00) {
    code >>= 16;
    if (((code >> 8) ^ (code & 0x00FF)) == 0x00FF) {
      return code & 0xFF;
    }
  }
  return -1;
}

void setup() {
  Serial.begin(9600);
  IrReceiver.begin(2);
  lcd_1.begin(16, 2);
  lcd_1.print("hello world");
}

void loop() {
  int button = readInfrared();
  if (button != -1) {
    // Do something with the button value, e.g., display on LCD
    lcd_1.clear();
    lcd_1.setCursor(0, 0);
    lcd_1.print("Button: ");
    lcd_1.print(button);
  }

  delay(10);
}

I moved your topic to an appropriate forum category @bigil3.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

1 Like

"invalid header file"

Paste both header files here for examination. Be sure to paste them in < CODE > blocks for structured reading.

  This is inside a code block.
  A quick brown fox jumps over the lazy dog.

This is not a code block.
A quick brown fox jumps over the lazy dog.

I have deleted your other cross-post @bigil3.

Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting can result in a suspension from the forum.

In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

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