Created
December 12, 2017 07:09
-
-
Save johnroyer/79879d947c9e488a9a96a2723576939b to your computer and use it in GitHub Desktop.
RPi + PIR sensor scan + LED output
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 | |
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