Invalid header file error

I am making a project on tinkercad and later in real life but it just keeps giving invalid header file error is there anybody who can help?
thanks

#include <LiquidCrystal_I2C.h>

#include <Wire.h>


LiquidCrystal_I2C lcd(0x27, 16, 2);  // Set the LCD address to 0x27 for a 16 chars and 2 line display

const int buttonYesPin = 2;  // Pin for the 'Yes' button
const int buttonNoPin = 3;   // Pin for the 'No' button
const int motorPin = 8;      // Pin for the DC motor
const int timerDuration = 420000; // 7 minutes in milliseconds

unsigned long startTime;
bool timerExpired = false;

void setup() {
  pinMode(buttonYesPin, INPUT_PULLUP);
  pinMode(buttonNoPin, INPUT_PULLUP);
  pinMode(motorPin, OUTPUT);

  lcd.init();                      // Initialize the LCD
  lcd.backlight();                // Turn on the backlight
  lcd.print("Answer Yes or No"); // Display initial message
  delay(2000);
  lcd.clear();
  
  startTime = millis(); // Start the timer
}

void loop() {
  unsigned long currentTime = millis();
  unsigned long elapsedTime = currentTime - startTime;

  if (elapsedTime >= timerDuration) {
    timerExpired = true;
  }

  if (!timerExpired) {
    // Display questions here
    // Check button presses and handle them
    // Update LCD display accordingly
  } else {
    // Activate DC motor
    digitalWrite(motorPin, HIGH);
    // You can also display a message on the LCD indicating the timer expired
    lcd.clear();
    lcd.print("Time's up!");
    while (true) {
      // Loop indefinitely after timer expiry
    }
  }
}

Bit of a mess.. :frowning:
Looks like 3 ino's in 1..
You got 3 setup()'s and 3 loops()'s..
And there's loose chat code in the middle??
Maybe just a bad copy??

good luck.. ~q

1 Like

@zortpeq, please use code tags properly; I've fixed your post (hopefully correctly)

If that is in tinkercad, throw tinkercad away. I've successfully compiled your last code in IDE 1.8.19. One warning on this line when compiling for a Nano; if you're using a 32-bit processor there should not be a warning.

const int timerDuration = 420000; // 7 minutes in milliseconds

If you're using an Uno/Mega or the likes, see if you can figure out why you get the warning and fix it.

2 Likes

thank you this helped me alot i used the IDE and changed the code from

const int timerDuration = 420000; // 7 minutes in milliseconds

to

unsigned long int timerDuration = 420000UL; // 7 minutes in milliseconds

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