from machine import Pin
from time import sleep
button_entrance = Pin(13, Pin.IN, Pin.PULL_UP)
button_exit = Pin(12, Pin.IN, Pin.PULL_UP)
led_pins = [2, 4, 5, 18, 16, 17, 22, 23]
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 not button_entrance.value() and car_count < 8:
car_count += 1
update_leds(car_count)
sleep(0.3)
if not button_exit.value() and car_count > 0:
car_count -= 1
update_leds(car_count)
sleep(0.3)