Skip to content

Instantly share code, notes, and snippets.

@brunokruse
Created July 28, 2016 16:53
Show Gist options
  • Save brunokruse/a5ae5e16dc15f4b7bf79ce8f54c36e55 to your computer and use it in GitHub Desktop.
Save brunokruse/a5ae5e16dc15f4b7bf79ce8f54c36e55 to your computer and use it in GitHub Desktop.
workshop
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)
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