#include <ESP32Servo.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define pinS1 34
#define pinServo1 18
Servo servo1;
LiquidCrystal_I2C lcd(0x27, 20, 4); // Change the I2C address if needed
int z1=0, z2=1, z3=0;
void setup() {
Serial.begin(115200);
Serial.println("Hola todes ");
servo1.attach(pinServo1);
pinMode(pinS1, INPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(5,1);
lcd.print("UCEVA");
delay(500);
lcd.clear();
delay(500);
lcd.setCursor(5,1);
lcd.print("UCEVA");
delay(500);
lcd.clear();
delay(500);
lcd.setCursor(5,1);
lcd.print("UCEVA");
delay(500);
lcd.clear();
delay(500);
lcd.setCursor(5,0);
lcd.print("PARQUEADERO");
}
void loop() {
if( digitalRead(pinS1) == 0 ){
z1 = 1;
Serial.println("Llego un carro a parquear");
servo1.write(120);
}
else{
servo1.write(0);
z1 = 0;
}
lcd.setCursor(0,2);
lcd.print("| | | |");
if( z1 == 1){
lcd.setCursor(1,2);
lcd.print("X");
}
else{
lcd.setCursor(1,2);
lcd.print("O");
}
delay(500); // this speeds up the simulation
}