Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import time
  3.  
  4. GPIO.setmode(GPIO.BCM)
  5.  
  6. GPIO.setup(4, GPIO.IN) #PIR
  7.  
  8. try:
  9. time.sleep(3) # to stabilize sensor
  10. while True:
  11. if GPIO.input(4):
  12. print("Motion Detected...")
  13. time.sleep(4) #to avoid multiple detection
  14. time.sleep(0.1) #loop delay, should be less than detection delay
  15. GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement