I purchased this PIR from Cool Components: http://www.coolcomponents.co.uk/catalog ... p-312.html.
I have followed a couple of tutorials but can't seem to get it working properly. The code I am using is:
Code: Select all
#!/usr/bin/python import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) GPIO_PIR = 7 print "PIR Module Test (CTRL-C to exit)" GPIO.setup(GPIO_PIR,GPIO.IN) Current_State = 0 Previous_State = 0 try: print "Waiting for PIR to settle ..." while GPIO.input(GPIO_PIR)==1: Current_State = 0 print " Ready" while True : Current_State = GPIO.input(GPIO_PIR) if Current_State==1 and Previous_State==0: print " Motion detected!" Previous_State=1 elif Current_State==0 and Previous_State==1: print " Ready" Previous_State=0 time.sleep(0.01) except KeyboardInterrupt: print " Quit" GPIO.cleanup()
It just keeps saying that motion is detected over and over. Even when i am in a different room.
Can anyone advise me on what to do???