print("This device will detect motion")
print("15/01/2024")
print("created by ZUNIE")

#import libraries
from machine import Pin, PWM
from utime import sleep

#Pin declaration
WARNING_LED = Pin(2, Pin.OUT)
SIGNAL_LED = Pin(4, Pin.OUT)
sensor_motion = Pin(12, Pin.IN)
BUZZER_pin = Pin(15, Pin.OUT)

while True:
    status_intruder = sensor_motion.value()
    if status_intruder == 1:
        print("There is INTRUDER!!!! HELPPPPPP!!!!!")
        for a in range (5):
            SIGNAL_LED.off()
            WARNING_LED.on()
            sleep(0.3)
            tone_buzzer = PWM(BUZZER_pin, freq = 1500 , duty = 50)
            sleep(0.03)
            WARNING_LED.off()
            sleep(0.3)
            tone_buzzer = PWM(BUZZER_pin, freq = 1500 , duty = 0)
            sleep(0.03)

    else:
        print("SANTAIII BRO MASIH BIASA")
        WARNING_LED.off()
        SIGNAL_LED.on()

    status_intruder = 0
    sleep(2)