Created
February 17, 2018 04:44
-
-
Save kentros/44a9ad332a8e6e07445be650b9a82d47 to your computer and use it in GitHub Desktop.
Passive Infrared Sensor code for a Raspberry Pi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import time | |
import os | |
GPIO.setmode(GPIO.BCM) | |
PIR_PIN = 25 | |
GPIO.setup(PIR_PIN, GPIO.IN) | |
def MOTION(PIR_PIN): | |
print 'Motion Detected! ' + time.ctime() | |
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 1: | |
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