Error in my smart parking system code

We needed to create a code for our project assignment. A smart parking system. I created my code as below, but I get the "Invalid header file" error. What should I do. Thank you for your help.

#include <LiquidCrystal_I2C.h>
#include <Wire.h> 
#include <Servo.h>

LiquidCrystal_I2C lcdekranim(0x27, 16, 2);

const int trigger_pin1 = 8;
const int echo_pin1 = 9;
const int trigger_pin2 = 10;
const int echo_pin2 = 11;

int sure1;
int mesafe1;
int sure2;
int mesafe2;

int irsensor1=3;
int irsensor2=4;

Servo giris;
Servo cikis;

int Kirmiziled=13;
int Yesilled=12;
int Beyazled=2;
int buzzerPin= 7;
int gazPin=A1;

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(2, OUTPUT);

  pinMode(trigger_pin1, OUTPUT);
  pinMode(echo_pin1, INPUT);
  pinMode(trigger_pin2, OUTPUT);
  pinMode(echo_pin2, INPUT);

pinMode(irsensor1,INPUT);
pinMode(irsensor2,INPUT);
pinMode(buzzerPin, OUTPUT);

giris.attach(6);
cikis.attach(5);


lcdekranim.init();
lcdekranim.backlight();
lcdekranim.SetCursor(1, 0);
lcdekranim.print("AKILLI OTOPARK");

lcdekranim.SetCursor(2, 1); 
lcdekranim.print("HOS GELDINIZ");

delay(6000);
lcdekranim.clear();

}
 
 void loop()
 {
lcdekranim.SetCursor(0, 0);
lcdekranim.print("A1");

lcdekranim.SetCursor(9, 0);
lcdekranim.print("A2");

//1.Ultrasonik sensör  
digitalWrite(trigger_pin1, HIGH);
delayMicroseconds(1000);
digitalWrite(trigger_pin1, LOW);
sure1 = pulseIN(echo_pin1, HIGH);
mesafe1 = (sure1/2) / 29.1; 


//2.Ultrasonik sensör 

digitalWrite(trigger_pin2, HIGH);
delayMicroseconds(1000);
digitalWrite(trigger_pin2, LOW);
sure2 = pulseIN(echo_pin2, HIGH);
mesafe2 = (sure2/2) / 29.1; 

if(mesafe1<=10) {
  lcdekranim.SetCursor(0,1);
  lcdekranim.print("DOLU");
}
else {
  lcdekranim.SetCursor(0,1);
  lcdekranim.print("BOS");
 }

if(mesafe2<=10) {
  lcdekranim.SetCursor(9,1);
  lcdekranim.print("DOLU");
}
 
 else {
  lcdekranim.SetCursor(9,1);
  lcdekranim.print("BOS");
 }

int irdeger1=digitalRead(irsensor1);
int irdeger2=digitalRead(irsensor2);

if (irdeger1==0)
{
  giris.write(0);
}

else {
  giris.write(90);
}

if (irdeger2==0)
{
  cikis.write(90);
}

else {
  cikis.write(0);
}

if(mesafe1<=10&&mesafe2<=10)
{
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);
}

else 
{
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);
}

int isik = analogRead(A0);
 
 if(isik>250)
{
digitalWrite(2, LOW);
}

if(isik<200)
{
digitalWrite(2, HIGH);
}

int gazDegeri = analogRead(A1);

if(gazDegeri > 500)
{
  digitalWrite(13, HIGH);
  tone(buzzerPin, 2000);
  delay(500);
  digitalWrite(13, LOW);
  noTone(buzzerPin);
  delay(500);
}

Welcome to the forum

Please post the full error message copied from the IDE using the button provided for the purpose

Actually, I first try to run it on Tinkercad and the error is exactly "Invalid header file".

2 white led
3 ir senspr 1
4 ir sensor 2
5 servo input
6 servo output
7 buzzer pin
8 trig pin 1
9 echo pin 1
10 trig pin 2
11 echo pin 2
12 green led
13 red led

a0 LDR
a1 gas pin

This is the second time today that I have seen this error reported from TinkerCAD without details being available, hence no resolution was possible in the other case

I can tell you everything you need in detail.

If all you get from TinkerCAD is "Invalid header file" then there is not much that can be given

The code also contains several errors such as mis-spelling the names of the the setCursor() and pulseIn() functions that would prevent the code from compiling

With those fixed the code compiles in IDE 2.3.2

A "Invalid header file" error can have many causes, and without the header filename (or, better, the complete error message and where it came out from) we can say nothing to help you. This is like going to a car mechanic saying "Hey, my car makes a bad noise": don't you expect to be given a specific answer to such a general question?

If you tried to run your code on Tinkercad please share here the project link so we can directly see what's wrong and why.

For comparison, this is the other topic with a similar error message

Taking what you said into consideration, I made some edits and ran it on the IDE. This is the current version of the code. I am also sharing with you the error I received on the IDE.

#include <LiquidCrystal_I2C.h>
#include <Wire.h> 
#include <Servo.h>

LiquidCrystal_I2C lcdekranim(0x27, 16, 2);

const int trigger_pin1 = 8;
const int echo_pin1 = 9;
const int trigger_pin2 = 10;
const int echo_pin2 = 11;

int sure1;
int mesafe1;
int sure2;
int mesafe2;

int irsensor1=3;
int irsensor2=4;

Servo giris;
Servo cikis;

int Kirmiziled=13;
int Yesilled=12;
int Beyazled=2;
int buzzerPin= 7;
int gazPin=A1;

void setup()
{
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(2, OUTPUT);

  pinMode(trigger_pin1, OUTPUT);
  pinMode(echo_pin1, INPUT);
  pinMode(trigger_pin2, OUTPUT);
  pinMode(echo_pin2, INPUT);

pinMode(irsensor1,INPUT);
pinMode(irsensor2,INPUT);
pinMode(buzzerPin, OUTPUT);

giris.attach(6);
cikis.attach(5);


lcdekranim.init();
lcdekranim.backlight();
lcdekranim.setCursor(1, 0);
lcdekranim.print("AKILLI OTOPARK");

lcdekranim.setCursor(2, 1); 
lcdekranim.print("HOS GELDINIZ");

delay(6000);
lcdekranim.clear();

}
 
 void loop()
 {
lcdekranim.setCursor(0, 0);
lcdekranim.print("A1");

lcdekranim.setCursor(9, 0);
lcdekranim.print("A2");

//1.Ultrasonik sensör  
digitalWrite(trigger_pin1, HIGH);
delayMicroseconds(1000);
digitalWrite(trigger_pin1, LOW);
sure1 = pulseIn(echo_pin1, HIGH);
mesafe1 = (sure1/2) / 29.1; 


//2.Ultrasonik sensör 

digitalWrite(trigger_pin2, HIGH);
delayMicroseconds(1000);
digitalWrite(trigger_pin2, LOW);
sure2 = pulseIn(echo_pin2, HIGH);
mesafe2 = (sure2/2) / 29.1; 

if(mesafe1<=10) {
  lcdekranim.setCursor(0,1);
  lcdekranim.print("DOLU");
}
else {
  lcdekranim.setCursor(0,1);
  lcdekranim.print("BOS");
 }

if(mesafe2<=10) {
  lcdekranim.setCursor(9,1);
  lcdekranim.print("DOLU");
}
 
 else {
  lcdekranim.setCursor(9,1);
  lcdekranim.print("BOS");
 }

int irdeger1=digitalRead(irsensor1);
int irdeger2=digitalRead(irsensor2);

if (irdeger1==0)
{
  giris.write(0);
}

else {
  giris.write(90);
}

if (irdeger2==0)
{
  cikis.write(90);
}

else {
  cikis.write(0);
}

if(mesafe1<=10&&mesafe2<=10)
{
  digitalWrite(12, LOW);
  digitalWrite(13, HIGH);
}

else 
{
  digitalWrite(12, HIGH);
  digitalWrite(13, LOW);
}

int isik = analogRead(A0);
 
 if(isik>250)
{
digitalWrite(2, LOW);
}

if(isik<200)
{
digitalWrite(2, HIGH);
}

int gazDegeri = analogRead(A1);

if(gazDegeri > 500)
{
  digitalWrite(13, HIGH);
  tone(buzzerPin, 2000);
  delay(500);
  digitalWrite(13, LOW);
  noTone(buzzerPin);
  delay(500);
}
}

I tested your code on Tinkercad, and commenting out the wire.h include, that error won't come out (obviously others came out due to the lack of Wire library) , so I suppose something bad is with Tinkercad Wire library.

Let me say I switched to Wokwi months ago, and I still find it much more useful and a better usage than Tinkercad: it's easier to make good looking drawings, automatic wires coloring when starting a GND or 5V wire, destination pin automatic enhanced to show where that specific wire can be natively connected (e.g. starting a GND connection, the GND pin on other devices are shown in white), and "custom devices" definitions, to name just the first things that come to mind.

I tried it on Wokwi and it doesn't show that header error at all, except for some other errors that must be corrected, like a "SetCursor()" method instead of "setCursor()", "pulseIN()" instead of "pulseIn()", and so on, and you have (at least) a missing bracket at the end of the code (the "loop()" is incomplete).
On top of that, you have a very bad indentation (maybe causing also the missing bracket), please don't write "casual" coding, load your sketch with the IDE and press Ctrl-T to make the code correctly indented.

So after reformatting the code, I strongly suggest you to switch to Wokwi instead of Tinkercad.

Thank you for your suggestions and help. I was able to recompile the code as follows and make the necessary connections and run it. Thank you again to those who helped.

#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>

LiquidCrystal_I2C lcdekranim(0x27, 16, 2);

const int trigger_pin1 = 8;
const int echo_pin1 = 9;
const int trigger_pin2 = 10;
const int echo_pin2 = 11;

int sure1;
int mesafe1;
int sure2;
int mesafe2;

int irsensor1 = 3;
int irsensor2 = 4;

Servo giris;
Servo cikis;

int Kirmiziled = 13;
int Yesilled = 12;
int Beyazled = 2;
int buzzerPin = 7;
int gazPin = A1;

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(2, OUTPUT);

  pinMode(trigger_pin1, OUTPUT);
  pinMode(echo_pin1, INPUT);
  pinMode(trigger_pin2, OUTPUT);
  pinMode(echo_pin2, INPUT);

  pinMode(irsensor1, INPUT);
  pinMode(irsensor2, INPUT);
  pinMode(buzzerPin, OUTPUT);

  giris.attach(6);
  cikis.attach(5);


  lcdekranim.begin();
  lcdekranim.backlight();
  lcdekranim.setCursor(1, 0);
  lcdekranim.print("AKILLI OTOPARK");

  lcdekranim.setCursor(2, 1);
  lcdekranim.print("HOS GELDINIZ");

  delay(6000);
  lcdekranim.clear();
}

void loop() {
  lcdekranim.setCursor(0, 0);
  lcdekranim.print("A1");

  lcdekranim.setCursor(9, 0);
  lcdekranim.print("A2");

  //1.Ultrasonik sensör
  digitalWrite(trigger_pin1, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigger_pin1, LOW);
  sure1 = pulseIn(echo_pin1, HIGH);
  mesafe1 = (sure1 / 2) / 29.1;


  //2.Ultrasonik sensör

  digitalWrite(trigger_pin2, HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigger_pin2, LOW);
  sure2 = pulseIn(echo_pin2, HIGH);
  mesafe2 = (sure2 / 2) / 29.1;

  if (mesafe1 <= 10) {
    lcdekranim.setCursor(0, 1);
    lcdekranim.print("DOLU");
  } else {
    lcdekranim.setCursor(0, 1);
    lcdekranim.print("BOS");
  }

  if (mesafe2 <= 10) {
    lcdekranim.setCursor(9, 1);
    lcdekranim.print("DOLU");
  }

  else {
    lcdekranim.setCursor(9, 1);
    lcdekranim.print("BOS");
  }

  int irdeger1 = digitalRead(irsensor1);
  int irdeger2 = digitalRead(irsensor2);

  if (irdeger1 == 0) {
    giris.write(0);
  }

  else {
    giris.write(90);
  }

  if (irdeger2 == 0) {
    cikis.write(90);
  }

  else {
    cikis.write(0);
  }

  if (mesafe1 <= 10 && mesafe2 <= 10) {
    digitalWrite(12, LOW);
    digitalWrite(13, HIGH);
  }

  else {
    digitalWrite(12, HIGH);
    digitalWrite(13, LOW);
  }

  int isik = analogRead(A0);

  if (isik > 70) {
    digitalWrite(2, LOW);
  }

  else {
    digitalWrite(2, HIGH);
  }

  int gazDegeri = analogRead(A1);

  if (gazDegeri > 550) {
    digitalWrite(13, HIGH);
    tone(buzzerPin, 2000);
    delay(500);
    digitalWrite(13, LOW);
    noTone(buzzerPin);
    delay(500);
  }
}

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