#include <ESP32Servo.h>
Servo myservo1;
const int IR1 = 12; // IR Sensor 1
const int IR2 = 14; // IR Sensor 2
int Slot = 4; // Enter Total number of parking Slots
int flag1 = 0;
int flag2 = 0;
void setup() {
  myservo1.setPeriodHertz(50); // standard 50 hz servo
    myservo1.attach(13); // attaches the servo on GPIO 13
      pinMode(IR1, INPUT);
        pinMode(IR2, INPUT);
        }
        void loop() {
          flag1 = digitalRead(IR1);
            flag2 = digitalRead(IR2);
              if (flag1 == 0 && flag2 == 1) {
                  if (Slot > 0) {
                        myservo1.write(180); // turns the servo to 180 degrees
                              delay(1000); // waits for a second
                                    myservo1.write(0);
                                          Slot = Slot - 1;
                                              } else {
                                                    myservo1.write(0);
                                                          Slot = Slot;
                                                              }
                                                                }
                                                                }