from machine import Pin
from time import sleep
#code steup
entry_btn = Pin(34,Pin.IN)
exit_btn = Pin(35,Pin.IN)
leds = [Pin(2,Pin.OUT),Pin(4,Pin.OUT),Pin(21,Pin.OUT),Pin(13,Pin.OUT),Pin(14,Pin.OUT),Pin(16,Pin.OUT),Pin(17,Pin.OUT),Pin(18,Pin.OUT)]
full_led=Pin(19,Pin.OUT)
power_led =Pin(15,Pin.OUT)
error_led = Pin(25,Pin.OUT)
#code
count = 0
power_led.value(1)
try:
while True:
if count >= 8 :
count = 8
entry_btnv = None
entry_btnv = entry_btn.value()
if entry_btnv == 1:
if count == 8:
count -= 1
sleep(0.1)
leds[count].value(1)
count += 1
sleep(0.1)
sleep(0.1)
if count == 8:
full_led.value(1)
else:
full_led.value(0)
exit_btnv = None
exit_btnv = exit_btn.value()
if exit_btnv == 1 :
sleep(0.1)
if count > 0:
count -= 1
leds[count].value(0)
#errors handling
except Exception as e :
print(e)
for i in range(4):
error_led.value(0)
sleep(0.5)
error_led.value(1)
sleep(0.5)
error_led.value(0)
sleep(0.5)
error_led.value(1)
green led = power
red led = full
yellow led = error
red = power wire
blue = negative signal
yellow = if conditional wire
black = circuit part
Enter car
LEDs
Exit car
Full
States Leds
Power
Errors