i have been trying to make an LED turn on when i move but i dont know what is wrong with the code i am very new to python and am only 12 please help
Code: Select all
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
PIR_PIN = 7
GPIO.setup(PIR_PIN, GPIO.IN)
GPIO.setup(11, GPIO.OUT)
GPIO.output (11, False)
try:
print "PIR Module Test (CTRL+C to exit)"
time.sleep(2)
print "Ready"
while True:
if GPIO.input(PIR_PIN):
print "Motion Detected!"
GPIO.output(11, True)
time.sleep(1)
except KeyboardInterrupt:
print " Quit"
GPIO.cleanup()
olly