from machine import Pin
from time import sleep
s3 = Pin(32, Pin.IN)
s2 = Pin(25, Pin.IN)
s1 = Pin(27, Pin.IN)
unlock = Pin(17, Pin.OUT)
alarm = Pin(4, Pin.OUT)
locked = Pin(5, Pin.OUT)
while True:
unlock.value(not s3.value() and s2.value() and s1.value()) # When (0, 1, 1)
alarm.value(s3.value() and not s2.value() and not s1.value()) # When (1, 0, 0)
locked.value(not (unlock.value() or alarm.value()))
if unlock.value() == 1:
state = "Unlocked"
elif alarm.value() == 1:
state = "Alarm"
else:
state = "Locked"
print(f"Number is: {s3.value()} {s2.value()} {s1.value()}")
print(f"State: {state}")
sleep(0.5)
S3
S2
S1
Unlock
Alarm
Locked