Created
October 27, 2017 08:06
-
-
Save WakeupTsai/2ec6a672068601f96b4bcb1d522f187b to your computer and use it in GitHub Desktop.
[PIR-test] Testing code for pir sensor #pir #raspberry
This file contains hidden or 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
Testing code for pir sensor |
This file contains hidden or 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 | |
GPIO.setmode(GPIO.BCM) | |
GPIO.setup(14, GPIO.IN) #PIR | |
try: | |
time.sleep(2) # to stabilize sensor | |
while True: | |
if GPIO.input(14): | |
print("Motion Detected...") | |
break | |
except: | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment