Invalid header file error!

Can someone Please help me solve this issue regarding my TinkerCad Sketch?

// C++ code
//

#include <LiquidCrystal_I2C.h>
#include <IRremote.h>

#define LEDG 2
#define BUZZER 3
#define IRPIN 4
#define VMOTOR 5
#define PINGPIN 10
#define DCMOTOR 11
#define SENSORM A1


//define motor rotation int
int rotate;

// LCD setup
LiquidCrystal_I2C lcd(0x26, 16, 2);

// set up variable for ultrasonic distance sensor
int dur, dist;

//Predefined Moisture levels
const int LEAKRISK =17;
const int LEAKDETECTED=40;

//Predefined Water Levels
const int RISKLVL = 30;
const int MINLVL = 60;

//Define 2 Buttons for controlling washing mahine
const int BTN0 = 0X0C;
const int BTN1 = 0X10;

int t = 0;
int x = 0;

void setup()
{
  Serial.begin(115200);
  pinMode(LEDG, OUTPUT); //LED
  pinMode(BUZZER, OUTPUT); //Buzzer
  IrReceiver.begin(IRPIN, ENABLE_LED_FEEDBACK); //IR Receiver
  pinMode(VMOTOR,OUTPUT); //Vibration Motor
  pinMode(DCMOTOR,OUTPUT); //DC Motor

  
  lcd.init();       // initialize LCD
  lcd.backlight();  // Turn on LCD
}

void loop()
{ 
  digitalWrite(LEDG, LOW);
   
  if (IrReceiver.decode()){
       
    int act = IrReceiver.decodedIRData.command;
    IrReceiver.resume();
        switch (act){
          case BTN0:
          
            if(x==2){
              normalWash();
              x++;
              t=1;
            }

            else if (x==3){
              delicateWash();
              x=1;
              t=1;
            }
            else{
              quickWash();
           	  x=2;
              t=1;
            }
                       
          	break;
          
          case BTN1:
        	  reset();
          	  t=1;
          	  x=0;
        	  break;
        }  
       
      }
 
  else
    ;
  
  monitoring();
  
  t++;
  
  //To start the Washing
  if (t>30 && x!=0){
    Serial.println("WASHING STARTED");
    switch (x){
      
      case 2:
        quickWashCycle();
        x=0;
        t=0;
        break;
      case 3:
        normalWashCycle();
        x=0;
        t=0;
        break;
      case 1:
       delicateWashCycle();
        x=0;
        t=0;
        break;
    }
      
  }
    else
      ;
  
  if (x==0)
    ;
  else
    delay(400);
 
}



//-------------------------Conditional Response----------------------------

//Alert sound 
void softbeep(){
  tone(BUZZER, 1000, 120);
  delay(150);
  tone(BUZZER, 1400, 150);
  delay(180);
  noTone(BUZZER);
}

//Warning response
void warning(){
  int moisture = map(analogRead(SENSORM), 0, 876, 0, 100);
  
  if (readWaterLevel() <= MINLVL){
    waterWarning();
  }
  else if (moisture >= LEAKRISK){
    moistureWarning();
  }
  
  for(int i=0;i<2;i++){
    tone(BUZZER, 900);
    delay(200);
    noTone(BUZZER);
    delay(200);
  }
  digitalWrite(VMOTOR, LOW);
  analogWrite(DCMOTOR, 0);
  delay(500);
  
}

//Emergency response
void emergency(){  
  
  analogWrite(DCMOTOR, 0);
  
  int moisture = map(analogRead(SENSORM), 0, 876, 0, 100);
  
  if (readWaterLevel() <= RISKLVL){
    waterLow();
  }
  else if (moisture > LEAKDETECTED){
    moistureDetected();
  }
  
  for(int i=0;i<5;i++){
    tone(BUZZER, 1500);
    delay(120);
    tone(BUZZER, 600);
    delay(120);
  }
  noTone(BUZZER);
  digitalWrite(VMOTOR, HIGH);
  delay(500);
  
  lcd.clear();
  
  while (t!=0){
    lcd.setCursor(0,0);
    lcd.print("Press 1 to RESET");
    buttonReading();
  }
}



//--------------DISPLAY WASH SELECTION------------------------
//quick wash selected
void quickWash(){
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Mode:");
  lcd.setCursor(7, 0);
  lcd.print("Quick");
}

//normal wash selected
void normalWash(){
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Mode:");
  lcd.setCursor(7, 0);
  lcd.print("Normal");
}

//delicate wash selected
void delicateWash(){
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Mode:");
  lcd.setCursor(7, 0);
  lcd.print("Delicate");
}

//--------------Display Water Levels--------------------
void waterOk(){
  lcd.setCursor(0,1);
  lcd.print("Water Level OK");
  delay(300);
}
void waterWarning(){
  lcd.setCursor(0,1);
  lcd.print("Check Water Lvl");
  delay(300);
}
void waterLow(){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("LOW WATER LEVEL");
  delay(300);
}

//--------------Display Mositure Levels--------------------
void moistureWarning(){
  lcd.clear();
  lcd.setCursor(0,1);
  lcd.print("MOISTURE WARNING");
  delay(300);
}
void moistureDetected(){
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("LEAK DETECTED");
  delay(300);
}
  
//-----------RESET BUTTON!!!--------------
//In case the reset button is pressed
void buttonReading(){
  if (IrReceiver.decode()){
       
    int act = IrReceiver.decodedIRData.command;
    IrReceiver.resume();
        switch (act){
          case BTN0:     
          	break;
          
          case BTN1:
        	  reset();
          	  t=1;
          	  x=0;
        	  break;
        }
  }
}
//Reset button action
void reset(){
  noTone(BUZZER);
  digitalWrite(VMOTOR, LOW);
  analogWrite(DCMOTOR, 0);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Machine Reset");
  delay(500);
}

//Cycle Completion
void cycleComplete(){
  analogWrite(DCMOTOR, 0);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Cycle Completed!!");
  digitalWrite(LEDG, HIGH);
  softbeep();
  delay(1000);
}

//--------WASHING MODES--------
//quick wash cycle
void quickWashCycle(){
  softbeep();
  
  int moisture = map(analogRead(SENSORM), 0, 876, 0, 100);
  
  if (readWaterLevel() >= MINLVL && moisture < LEAKRISK){
    waterOk();
    
    lcd.clear();
    lcd.setCursor(0, 0);
    lcd.print("WASHING...     ");
    
    analogWrite(DCMOTOR, 220);
    
    for (int aa = 50; aa >0 ; aa++){ 
   
      //To reset Machine
      buttonReading();
      if (t==1)
        break;
      else;

      int moisture = map(analogRead(SENSORM), 0, 876, 0, 100);

      if (readWaterLevel() < RISKLVL || moisture > LEAKDETECTED) {
        emergency();
        break;
      }
      else if (readWaterLevel() < MINLVL || moisture > LEAKRISK) {
        warning();
        break;
      }
    
      else;
    
      delay (200);
    
      if (aa==1){
        cycleComplete();
      }
    
      else
        ;
    }
  
  }
}

//Normal wash cycle
void normalWashCycle(){
  
 
}

//Delicate wash cycle
void delicateWashCycle(){
  
  
}


//-----------------------READINGS-----------------------
int readWaterLevel() {
  pinMode(PINGPIN, OUTPUT);
  digitalWrite(PINGPIN, LOW);
  delayMicroseconds(2);
  digitalWrite(PINGPIN, HIGH);
  delayMicroseconds(10);
  digitalWrite(PINGPIN, LOW);
  pinMode(PINGPIN, INPUT);


  dur = pulseIn(PINGPIN, HIGH, 30000);
  if (dur == 0) return 200;
  dist = ((dur * .0343) / 2);
  return map(dist, 0, 208, 100, 0);
}
    
//---------------------Monitoring mode--------------------------

// to hold reading from moisture sensor and gave new range of 0-99
void monitoring(){
  int moisture = map(analogRead(SENSORM), 0, 876, 0, 100);

  if (readWaterLevel() < RISKLVL)
    waterOk();
  else if(readWaterLevel() < MINLVL)
    waterWarning();
  else if(moisture > LEAKDETECTED)
    moistureDetected();
}
       
//UPDATED!!!

here is a link to my tinkercad lab if needed

Welcome to the forum

Please post the full error message and .h file here
Most forum members are not users of TinkerCad

Sure. Don't use TinkerCad if you're a beginner.

Seriously. Don't use it.

Why? Because TinkerCad seems to use the generic "Invalid header file" error to address a multitude of problems without telling you what problem it encountered.

Which, for a beginner, is absolutely, totally, and in all other ways, completely and utterly useless. It's right up there with "Something went wrong".

Here's the result of running your sketch through the Arduino compilation process. As you can see, there are no errors, but there are a multitude of warnings. I'll leave you to read through them. I have no idea which, if any, of the warnings are upsetting TinkerCad. It could be the IRremote library mismatch. It could be the oddball else's. It could be the warning from the LiquidCrystal_I2C library. Or it could be something else.

Oh, and I'll just note in parting that had you compiled this with the Arduino IDE or CLI, it would have compiled. It might not have done what you wanted, but it would have compiled. And you could have already uploaded it to real hardware and begun to debug it.

Instead of, you know, fighting with a 3rd party tool that's too useless to give useful error messages. But it's your time. Spend it as you please.

arduino-cli compile -b arduino:avr:uno --warnings all --output-dir ~/tmp --no-color (in directory: /home/me/Documents/sketchbook/Uno_R3/test)
In file included from /home/me/Documents/sketchbook/Uno_R3/test/test.ino:5:0:
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:12:2: warning: #warning Thank you for using the IRremote library! [-Wcpp]
 #warning Thank you for using the IRremote library!
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:13:2: warning: #warning It seems, that you are using a old version 2.0 code / example. [-Wcpp]
 #warning It seems, that you are using a old version 2.0 code / example.
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:14:2: warning: #warning This version is no longer supported! [-Wcpp]
 #warning This version is no longer supported!
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:15:2: warning: #warning Please use one of the new code examples from the library available at "File > Examples > Examples from Custom Libraries / IRremote". [-Wcpp]
 #warning Please use one of the new code examples from the library  available at "File > Examples > Examples from Custom Libraries / IRremote".
  ^~~~~~~
In file included from /home/me/Documents/sketchbook/Uno_R3/test/test.ino:5:0:
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:16:2: warning: #warning Or downgrade your library to version 2.6.0. [-Wcpp]
 #warning Or downgrade your library to version 2.6.0.
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:17:2: warning: #warning Start with the SimpleReceiver or SimpleSender example. [-Wcpp]
 #warning Start with the SimpleReceiver or SimpleSender example.
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:18:2: warning: #warning The examples are documented here: https: [-Wcpp]
 #warning The examples are documented here: https://github.com/Arduino-IRremote/Arduino-IRremote#examples-for-this-library
  ^~~~~~~
/home/me/Documents/sketchbook/libraries/IRremote/src/IRremote.h:19:2: warning: #warning A guide how to convert your 2.0 program is here: https: [-Wcpp]
 #warning A guide how to convert your 2.0 program is here: https://github.com/Arduino-IRremote/Arduino-IRremote#converting-your-2x-program-to-the-4x-version
  ^~~~~~~
/home/me/Documents/sketchbook/Uno_R3/test/test.ino: In function 'void loop()':
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:94:5: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
     ;
     ^
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:124:7: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
       ;
       ^
/home/me/Documents/sketchbook/Uno_R3/test/test.ino: In function 'void quickWashCycle()':
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:327:11: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
       else;
           ^
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:340:11: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
       else;
           ^
/home/me/Documents/sketchbook/Uno_R3/test/test.ino:349:9: warning: suggest braces around empty body in an 'else' statement [-Wempty-body]
         ;
         ^
/home/me/Documents/sketchbook/libraries/LiquidCrystal_I2C/LiquidCrystal_I2C.cpp: In member function 'void LiquidCrystal_I2C::begin(uint8_t, uint8_t, uint8_t)':
/home/me/Documents/sketchbook/libraries/LiquidCrystal_I2C/LiquidCrystal_I2C.cpp:71:39: warning: unused parameter 'cols' [-Wunused-parameter]
 void LiquidCrystal_I2C::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
                                       ^~~~
Sketch uses 17166 bytes (53%) of program storage space. Maximum is 32256 bytes.
Global variables use 1153 bytes (56%) of dynamic memory, leaving 895 bytes for local variables. Maximum is 2048 bytes.
Compilation finished successfully.

FYI
there are a number of topics on the forum about the "invalid header file" error in tinkercad.

You can always compile in the IDE to test and after successful compilation put your program in tinkercad; you do not need to have a board connected to be able to compile in the IDE.

The warnings on else; are just to tell that the else is empty. This is not an error, it is just a bit of superfluous code.

Simply remove it to get rid of the warnings.

I'm not the OP, and I'm fully aware of the difference between a warning and an error, and I can read both warning and error messages and understand their meaning, thank you.

I know you know. I copied the quote from your post. So the forum set my post as a reaction to your post...
Sorry...
It was meant for the OP.

If the issue is "Invalid header file error!" then I would say libraries are missing. The two libraries you need are in the top of the sketch.

The IRremote.h library has been updated to IRremote.hpp so you will probably see a warning if only IRremote.h is #included.

And... your sketch is full of strange entries, namely

  • else ;... which the IDE does not like and suggests replacing the semi-colon ; with braces {}... but then you should examine "why" you have an else { // do nothing } anywhere in your sketch, and just remove them.
  • void normalWashCycle() and void delicateWashCycle() are empty functions.
  • rotate is not used.
  • I think the address of the lCD is 0x27

Other than lacking functions, the code "works"... but does not recover from LEAK mode unless RESET is pressed on the remote.

@hershi - Describe how this code will work in steps, from start to stop. This is called "theory of operation" and is provided in every User Manual so you understand how to use the item. So, please, write something like:

  1. Apply power
  2. LCD shows "something"
  3. Press remote button "(this button")
  4. Code does this
  5. LEDs do that
  6. LCD shows "these"
  7. and this button
  8. and that motor
  9. and the other moisture level

You code has a lot of "unused" commands. Leaving them in does not stop it from running (I ran it, pressed buttons, change the moisture (potentiometer), but removing the unused commands changes the result (because doing that allows or blocks the very next command). So, please, provide a theory of operation.