Skip to content

Instantly share code, notes, and snippets.

@johnroyer
Created December 12, 2017 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnroyer/79879d947c9e488a9a96a2723576939b to your computer and use it in GitHub Desktop.
Save johnroyer/79879d947c9e488a9a96a2723576939b to your computer and use it in GitHub Desktop.
RPi + PIR sensor scan + LED output
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
# LED
GPIO.setup(3, GPIO.OUT)
# PIR sensor
GPIO.setup(11, GPIO.IN)
# set LED to OFF
GPIO.output(3, 0)
while True:
data = GPIO.input(11)
if data == 0:
GPIO.output(3, 0)
time.sleep(1)
else :
GPIO.output(3, 1)
time.sleep(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment