Interfacing HCSR501 Motion sensor Raspberry PI PICO

Interfacing HCSR501 Motion sensor Raspberry PI PICO




#In this project we will configure the Raspberry pi pico as an alarm System.
#In normal state the GPIO pin 28 is looking a +4 volt is available from the PIR sensor output.
#if there in no +4volt received in GPIO 28,Raspberry pi pico will trigger the interrupt the-
#normal duty of LED(Toggling Every 5 second interval the system is running normal)
# and Perform  the task which we defined in the def function.
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(" 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)
sensor_pir.irq(trigger=machine.Pin.IRQ_FALLING, handler=pir_handler)

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


 

Comments

Popular posts from this blog

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico