Comments on: Raspberry Pi Pico: Detect Motion using a PIR Sensor (MicroPython) https://randomnerdtutorials.com/raspberry-pi-pico-motion-pir-micropython/ Learn ESP8266, ESP32, Arduino, and Raspberry Pi Tue, 15 Oct 2024 20:41:25 +0000 hourly 1 https://wordpress.org/?v=6.8.2 By: Stuart https://randomnerdtutorials.com/raspberry-pi-pico-motion-pir-micropython/#comment-972381 Tue, 15 Oct 2024 20:41:25 +0000 https://randomnerdtutorials.com/?p=136663#comment-972381 Thanks. Nice guide. Very clear. I liked the interrupt example.
Cut back, ultra simplified version here:
from machine import Pin
import time

pir_pin = Pin(16, Pin.IN)

led_pin = Pin(25, Pin.OUT)

def pir_interrupt(pin):
if pin.value() == 1:
led_pin.value(1)
else:
led_pin.value(0)

Configure the interrupt on the PIR pin for both rising and falling edges

pir_pin.irq(trigger=(Pin.IRQ_RISING | Pin.IRQ_FALLING), handler=pir_interrupt)

looping = True
while looping == True:
print(“Just looping…”)
time.sleep(1)

I am developing Physical Computing at my school. Thank you.

]]>