Hi everyone, Im a little lost on a school project and could use some advice. Its essentially a home security system where some push buttons allow the user to enter a passcode to arm or disarm the security protocols. The issue im encountering is when the system is Armed a countdown is started (lets say 10 seconds) when motion is detected. This countdown gives time for the user to enter the passcode to disarm the system before it activates the alarm.
im trying to code this in CircuitPython and im having some issues.
def alarm():
global photoresistor
attempt = 0
photoresistor.deinit()
led = DigitalInOut(board.A0)
led.direction = Direction.OUTPUT
led.value = True
while True:
user_pass = PES()
if user_pass == ref_passcode:
led.value = False
led.deinit()
photoresistor = analogio.AnalogIn(board.A0)
security_sys()
elif user_pass != ref_passcode:
print("Incorrect")
attempt += 1
if attempt == 3:
print("ALARM ACTIVATED")
while True:
led.value = True
time.sleep(1)
led.value = False
time.sleep(1)
# CONTINUOUS ALARM
This is my alarm function. I want to add a timer using time.monotonic(), but I cant do that and call my password function -- that allows the user to input their passcode because it blocks the timer from running.