I ma trying to do something simple, I want to test the PIR motion sensor (PIR HC-SR501) I have.
I connected to GND, Vc5 and GPIO4. I tried to run below code, but it alwasy detect motion, I dont understand why! I disconnected the sensor and I ran it again and It also detect motion event if it is not plugged any more... any idea?
Code: Select all
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN)
#Read output from PIR motion sensor
#GPIO.setup(3, GPIO.OUT)
#LED output pin
print "Ready"
while True:
if GPIO.input(7):
print "Motion Detection"
time.sleep(1)
