Skip to content

Instantly share code, notes, and snippets.

@WakeupTsai
Created October 27, 2017 08:06
Show Gist options
  • Save WakeupTsai/2ec6a672068601f96b4bcb1d522f187b to your computer and use it in GitHub Desktop.
Save WakeupTsai/2ec6a672068601f96b4bcb1d522f187b to your computer and use it in GitHub Desktop.
[PIR-test] Testing code for pir sensor #pir #raspberry
Testing code for pir sensor
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