void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  Serial.println("Hello, ESP32!");
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(10); // this speeds up the simulation
}
from machine import Pin
import time

led_pins = [2, 4, 5, 13, 14, 16, 17, 18]
leds = [Pin(pin, Pin.OUT) for pin in led_pins]

btn_entrance = Pin(34, Pin.IN)
btn_exit = Pin(35, Pin.IN)

car_count = 0

def update_leds(count):
    for i in range(8):
        leds[i].value(1 if i < count else 0)

last_entrance = 1
last_exit = 1

while True:
    current_entrance = btn_entrance.value()
    current_exit = btn_exit.value()

    if last_entrance == 1 and current_entrance == 0:
        if car_count < 8:
            car_count += 1
            update_leds(car_count)
        time.sleep(0.2)

    if last_exit == 1 and current_exit == 0:
        if car_count > 0:
            car_count -= 1
            update_leds(car_count)
        time.sleep(0.2)

    last_entrance = current_entrance
    last_exit = current_exit