#include <Servo.h> //includes the servo library
#include <Wire.h>
#include <LiquidCrystal_I2C.h> //includes LiquidCrystal_I2C library
LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo myservo;
int S1=0;
int sensor1 =4;
int sensor2 = 5;
int slot = 1 ;
int val1= 0;
int val2= 0;
void setup() {
Serial.begin(9600);
myservo.attach(9);
myservo.write(90);
lcd.backlight();
lcd.begin(16,2);
lcd.setCursor (1,0);
lcd.print(" Arduino ");
lcd.setCursor (1,1);
lcd.print("Parking System");
delay (2000);
lcd.clear();
}
void loop() {
val1 = digitalRead(sensor2);
int total= val1;
slot = 1-total;
if (slot>0)
{
lcd.setCursor (0,0);
lcd.print(" Have Slot: ");
lcd.print(slot);
}
else
{
lcd.setCursor(2,0);
lcd.print("parking full");
}
val2 = digitalRead(sensor1);
int gate= val2;
if(gate==1)
{
myservo.write(180);
delay(2000);
}
else
{
myservo.write(90);
}
}