from machine import Pin
import time

entrance_button = Pin(34, Pin.IN)
exit_button = Pin(35, Pin.IN)

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

car_count = 0

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

while True:
    if entrance_button.value() == 1:
        if car_count < 8:
            car_count += 1
            update_leds(car_count)
        time.sleep(0.5)

    if exit_button.value() == 1:
        if car_count > 0:
            car_count -= 1
            update_leds(car_count)
        time.sleep(0.5)