Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(4, GPIO.IN) #PIR
- try:
- time.sleep(3) # to stabilize sensor
- while True:
- if GPIO.input(4):
- print("Motion Detected...")
- time.sleep(4) #to avoid multiple detection
- time.sleep(0.1) #loop delay, should be less than detection delay
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement