Skip to content

Instantly share code, notes, and snippets.

@lily-mara
Last active August 29, 2015 14:10
Show Gist options
  • Save lily-mara/2ee6dd5f2bbf2313b983 to your computer and use it in GitHub Desktop.
Save lily-mara/2ee6dd5f2bbf2313b983 to your computer and use it in GitHub Desktop.
example code for pir motion detector
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
PIR_PIN = 7
GPIO.setup(PIR_PIN, GPIO.IN)
def MOTION(PIR_PIN):
print 'Motion Detected!'
print 'PIR Module Test (CTRL+C to exit)”
time.sleep(2)
print 'Ready'
try:
GPIO.add_event_detect(PIR_PIN, GPIO.RISING, callback=MOTION)
while True:
time.sleep(100)
except KeyboardInterrupt:
print ' Quit'
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment