#define BLYNK_TEMPLATE_ID "TMPL61LAvUl0t"
#define BLYNK_TEMPLATE_NAME "Quickstart Template"
#define BLYNK_AUTH_TOKEN "CeJZx31QAfVYqWiT_uXnvfPlSZk40Wlj"
#include <ESP32Servo.h>
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2);
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#include <Servo.h>
Servo myservo1;
int IR1 = 13 ;
int IR2 = 12 ;
int Slot = 4; //Enter Total number of parking Slots
int flag1 = 0;
int flag2 = 0;
void setup() {
lcd.begin();
lcd.backlight();
pinMode(IR1, INPUT);
pinMode(IR2, INPUT);
myservo1.attach(26);
myservo1.write(100);
lcd.setCursor (0,0);
lcd.print(" polimdo ");
lcd.setCursor (0,1);
lcd.print(" tempat parkir kampus ");
delay (2000);
lcd.clear();
}
void loop(){
if(digitalRead (IR1) == LOW && flag1==0){
if(Slot>0){flag1=1;
if(flag2==0){myservo1.write(0); Slot = Slot-1;}
}else{
lcd.setCursor (0,0);
lcd.print(" maaf :( ");
lcd.setCursor (0,1);
lcd.print(" tempat parkir penuh ");
delay (3000);
lcd.clear();
}
}
if(digitalRead (IR2) == LOW && flag2==0){flag2=1;
if(flag1==0){myservo1.write(0); Slot = Slot+1;}
}
if(flag1==1 && flag2==1){
delay (1000);
myservo1.write(100);
flag1=0, flag2=0;
}
lcd.setCursor (0,0);
lcd.print(" selamat datang ");
lcd.setCursor (0,1);
lcd.print("Slot tersedia: ");
lcd.print(Slot);
}