print("This device will detect motion")
print("Date: 22/11/2023")
print("Created by AIA")

#import libraries
from machine import Pin 
from utime import sleep

#Pin declaration
red_led= Pin(14, Pin.OUT)
blue_led= Pin(2, Pin.OUT)
sensor_motion= Pin(12, Pin.IN)

while True:
  status_intruder= sensor_motion.value()
  if status_intruder == 1:
    print("There is INTRUDER! HELP!!!")
    for a in range(5):
      red_led.on()
      sleep(0.5)
      red_led.off()
      sleep(0.2)
      blue_led.on()
      sleep(0.2)
      blue_led.off()
      sleep(0.2)

  else:
    print("AMAN JAA TENANG TENANG")
    red_led.off()

  status_intruder == 0
  sleep(2) #In every 2 sec, check motion