from time import sleep
from machine import Pin
pir = Pin(28, Pin.IN)
rled = Pin(2, Pin.OUT)
rbutton = Pin(1, Pin.IN, Pin.PULL_UP)
print("PIR in Action ")
while True:
if(rbutton.value() == 0):
print("the PIR system is active")
for i in range(5):
if pir.value() == 1:
rled.on()
print("Motion is detected")
sleep(3)
else:
rled.off()
print("Motion is Not detected")
sleep(2)
sleep(10)
print("The PIR system is deactive")
else:
print("press the button to activate the PIR")
sleep(2)