from machine import Pin
from time import sleep

led_1 = Pin(2, Pin.OUT)
led_2 = Pin(4, Pin.OUT)
led_3 = Pin(5, Pin.OUT)
led_4 = Pin(13, Pin.OUT)
led_5 = Pin(14, Pin.OUT)
led_6 = Pin(16, Pin.OUT)
led_7 = Pin(17, Pin.OUT)
led_8 = Pin(18, Pin.OUT)

leds = [led_1, led_2, led_3, led_4, led_5, led_6, led_7, led_8]

Entrance_Button = Pin(35, Pin.IN)
Exit_Button = Pin(34, Pin.IN)

Car_Counter = 0
Parking_Full = 8

def Car_Leds(Counter):
    for C in range(8):
        if C < Counter and Counter <= Parking_Full :
            leds[C].value(1)
        else:
            leds[C].value(0)

while True:
    if Entrance_Button.value() == 1:
        if Car_Counter < 8:
            Car_Counter += 1
            Car_Leds(Car_Counter)
            sleep(0.2)
    elif Exit_Button.value() == 1 :
        if Car_Counter > 0:
            Car_Counter -=1
            Car_Leds(Car_Counter)
            sleep(0.2)