print("This is anti theft system")
print("created by : oyen")
print("date : 24/3/2025")
#Import libraries/modules
from machine import Pin, PWM
from utime import sleep
#Pin Declaration
pir_pin = Pin(33, Pin.IN)
led_red = Pin(18, Pin.OUT)
led_green = Pin(21, Pin.OUT)
buzzer_pin =PWM(Pin(25, Pin.OUT))
#Parameter Declaration (optional)
count_intruder = 0
#Main program
while True:
motion_status = pir_pin.value() #.value -->digital .read --> analog
if motion_status == 1: #1 means object detected
print("help! there is an intruder!")
for blink in range(5):
led_red.on()
buzzer_pin.init(freq=5000, duty = 512)
sleep(0.2)
led_red.off()
buzzer_pin.init(freq=5000 , duty=0)
sleep(0.2)
count_intruder = count_intruder + 1
print("frequency of object detected -- >", count_intruder)
else:
print("alhadulillah, semua selamat")
led_green.on()
led_red.off()
buzzer_pin.init(freq=5000, duty=0)
sleep(2) #system delay
esp:0
esp:2
esp:4
esp:5
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:21
esp:22
esp:23
esp:25
esp:26
esp:27
esp:32
esp:33
esp:34
esp:35
esp:3V3
esp:EN
esp:VP
esp:VN
esp:GND.1
esp:D2
esp:D3
esp:CMD
esp:5V
esp:GND.2
esp:TX
esp:RX
esp:GND.3
esp:D1
esp:D0
esp:CLK
pir1:VCC
pir1:OUT
pir1:GND
led1:A
led1:C
r1:1
r1:2
led2:A
led2:C
bz1:1
bz1:2