print("Let's detect intruder at our house")
print('Date: 23/11/2023')
print('Created by Adib')
#Import Libraries
from machine import Pin
from utime import sleep
#Declare Pin other than VCC and GND
red_alarm = Pin(5, Pin.OUT)
green_alarm = Pin(18, Pin.OUT)
pir = Pin(13, Pin.IN)
#Main Program
while True:
motion = pir.value()
if motion == 1: #1 means there is a motion
print('Tolong ada Pencuri!')
for b in range(3):
green_alarm.off()
red_alarm.on()
sleep(0.5)
red_alarm.off()
sleep(0.5)
else:
print('Alhamdulillah Selamat')
for b in range(100):
red_alarm.off()
green_alarm.on()
sleep(2) #In every 2 sec, check other motion