hello, i been trying to make one project in Tinkercad but after I finish writing code, I keep getting error "invalid header file". what should I do?
#include <Servo.h>
#include <Wire.h>
#include <Adafruit_LiquidCrystal.h>
#include <IRremote.h>
// Pin definitions
const int redLedPin = 11;
const int greenLedPin = 10;
const int servoPin = 12;
const int irReceiverPin = 13;
const int trigPin = 3;
const int echoPin = 4;
// Servo object
Servo gateServo;
// LCD object
Adafruit_LiquidCrystal lcd(0); // Use default I2C address 0x20
// IR remote
IRrecv irrecv(irReceiverPin);
decode_results results;
// Variables
long duration;
int distance;
void setup() {
// Initialize pins
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// Initialize servo
gateServo.attach(servoPin);
gateServo.write(0); // Ensure gate is closed initially
// Initialize LCD
lcd.begin(16, 2);
lcd.print("Gate Simulator");
// Initialize IR receiver
irrecv.enableIRIn();
}
void loop() {
// Measure distance with ultrasonic sensor
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration * 0.034 / 2;
// Check if object is near
if (distance < 20) {
lcd.clear();
lcd.print("Choose button 2");
lcd.setCursor(0, 1);
lcd.print("to open gate!");
// Check for IR remote input
if (irrecv.decode(&results)) {
if (results.value == 0xFF18E7) { // Button 2 (You might need to change this value based on your remote)
digitalWrite(greenLedPin, HIGH);
digitalWrite(redLedPin, LOW);
gateServo.write(90); // Open gate
lcd.clear();
lcd.print("Correct button,");
lcd.setCursor(0, 1);
lcd.print("have a nice ride!");
delay(3000); // Keep gate open for 3 seconds
gateServo.write(0); // Close gate
digitalWrite(greenLedPin, LOW);
} else {
digitalWrite(redLedPin, HIGH);
digitalWrite(greenLedPin, LOW);
lcd.clear();
lcd.print("Wrong button,");
lcd.setCursor(0, 1);
lcd.print("try again");
delay(1000); // Brief delay for wrong button feedback
digitalWrite(redLedPin, LOW);
}
irrecv.resume(); // Receive the next value
}
} else {
lcd.clear();
lcd.print("Waiting for car...");
}
delay(100);
}