PIR Motion Sensor Raspberry Pi (in 1 minute)

Опубликовано: 23 Октябрь 2024
на канале: Danny Murray
8,912
102

How to connect a PIR sensor to a raspberry pi and run some code in python. Here's the code in Python:

from gpiozero import MotionSensor
pir = MotionSensor(12) # out plugged into GPIO12
while True:
print("Continue scanning for humans...")
pir.wait_for_motion()
print("Moving human detected! Destroy human!")
pir.wait_for_no_motion()
print("Human deactivated...")