Created
July 28, 2016 16:53
-
-
Save brunokruse/a5ae5e16dc15f4b7bf79ce8f54c36e55 to your computer and use it in GitHub Desktop.
workshop
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) | |
GPIO.setup(11, GPIO.IN) #Read output from PIR motion sensor | |
GPIO.setup(3, GPIO.OUT) #LED output pin | |
while True: | |
i=GPIO.input(11) | |
if i==0: #When output from motion sensor is LOW | |
print "No intruders",i | |
GPIO.output(3, 0) #Turn OFF LED | |
time.sleep(0.1) | |
elif i==1: #When output from motion sensor is HIGH | |
print "Intruder detected",i | |
GPIO.output(3, 1) #Turn ON LED | |
time.sleep(0.1) |
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) | |
GPIO.setup(3,GPIO.OUT) #Define pin 3 as an output pin | |
while True: | |
GPIO.output(3,1) #Outputs digital HIGH signal (5V) on pin 3 | |
time.sleep(1) #Time delay of 1 second | |
GPIO.output(3,0) #Outputs digital LOW signal (0V) on pin 3 | |
time.sleep(1) #Time delay of 1 second |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment