from machine import Pin
from time import sleep
S_sw = Pin(13, Pin.IN)
L_sw = Pin(12, Pin.IN)
V_sw = Pin(14, Pin.IN)
F_sw = Pin(27, Pin.IN)
S_led = Pin(23, Pin.OUT)
L_led = Pin(22, Pin.OUT)
V_led = Pin(21, Pin.OUT)
F_led = Pin(19, Pin.OUT)
BT_led = Pin(2, Pin.OUT)
print("=== Sistema de control del toldo automático ===")
while True:
S = S_sw.value()
L = L_sw.value()
V = V_sw.value()
F = F_sw.value()
S_led.value(S)
L_led.value(L)
V_led.value(V)
F_led.value(F)
BT = ((L == 1) or (S == 1) or (V == 1)) and not ((S == 1) and (F == 1) and (V == 1))
BT_led.value(1 if BT else 0)
estado = "EXTENDIDO" if BT else "RECOGIDO"
print(f"Sol:{S} Lluvia:{L} Viento:{V} Frío:{F} -> Toldo: {estado}")
sleep(0.5)