# P10: Utilize um push button, dois leds e um sensor
# de radiação infravermelha (PIR):
# ▪ ao pressionar o push button, o circuito verifica
# se há movimento. Em caso afirmativo, o led 1
# acende, em caso negativo, o led 2 acende;
# ▪ Dois leds não ficam acesos ao mesmo tempo.
from machine import Pin
from time import sleep
bot = Pin(16,Pin.IN,Pin.PULL_UP)
lr = Pin(0,Pin.OUT)
lg = Pin(5,Pin.OUT)
# lr = Pin(0,Pin.IN,Pin.PULL_UP)
PIR = Pin(28,Pin.IN)
def PIR_SENSOR(args):
# try:
if PIR.value() == 1:
lr.on()
lg.off()
sleep(1)
if PIR.value() == 0:
lr.off()
lg.on()
sleep(1)
# except:
# else:
# print(f"\n Falha sistemica detectada!")
bot.irq(handler = PIR_SENSOR ,trigger = Pin.IRQ_FALLING)
while True:
lr.off()
lg.off()
print("\nComponent's OK!")
sleep(10)