Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Miftahul Akhyar 98767
Published © GPL3+

Burglar Alarm Using Raspberry Pi Pico

The burglar alarm 🚨 this a system that uses a motion sensor (PIR Sensor) to detect intruders. The system will flash the light and beep.

AdvancedFull instructions provided3 hours2,408
Burglar Alarm Using Raspberry Pi Pico

Things used in this project

Hardware components

PIR Sensor, 7 m
PIR Sensor, 7 m
×1
LED (generic)
LED (generic)
×1
Resistor 330 ohm
Resistor 330 ohm
×1
Raspberry Pi Pico
Raspberry Pi Pico
×1
Buzzer
Buzzer
×1

Story

Read more

Schematics

screenshot_(158)_qBx2HCHS6X.png

Code

Untitled file

Python
import machine
import utime

sensor_pir = machine.Pin(28,machine.Pin.IN)
led = machine.Pin(15, machine.Pin.OUT)
buzzer = machine.Pin(14, machine.Pin.OUT)

def pir_handler(pin):
    print("ALARM! Motion detected!")
    for i in range (50):
        led. toggle()
        buzzer.toggle()
        utime.sleep_ms(200)
        
sensor_pir.irq(trigger=machine.Pin.IRQ_RISING,handler=pir_handler)

while True:
    led.toggle()
    utime.sleep(5)

Credits

Miftahul Akhyar 98767
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.