Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import picamera # Importing the library for camera module
- from time import sleep
- import RPi.GPIO as GPIO
- import time
- import test
- GPIO.setmode(GPIO.BCM)
- GPIO.setwarnings(False)
- GPIO.setup(26, GPIO.IN) #PIR
- GPIO.setup(25, GPIO.IN) # Door Switch1
- GPIO.setup(24, GPIO.IN) # Door Switch2
- GPIO.setup(12, GPIO.OUT) #Buzzer
- try:
- time.sleep(2) # to stabilize sensor
- while True:
- if GPIO.input(26):
- GPIO.output(12, True)
- time.sleep(1) #Buzzer turns on for 2 sec
- GPIO.output(12, False)
- print("Motion Detected...")
- time.sleep(1) #to avoid multiple detection
- time.sleep(0.1) #loop delay, should be less than detection delay
- camera = picamera.PiCamera() # Setting up the camera
- sleep(2)
- camera.capture('/home/pi/Downloads/imag1.jpg') # Capturing the image
- camera.close()
- time.sleep(1) #loop delay, should be less than detection delay
- exec(open("test.py").read())
- if GPIO.input(25):
- GPIO.output(12, GPIO.LOW)
- else:
- GPIO.output(12,GPIO.HIGH)
- print("Door is opened....")
- time.sleep(1) #to avoid multiple detection
- if GPIO.input(24):
- GPIO.output(12, GPIO.LOW)
- else:
- GPIO.output(12,GPIO.HIGH)
- print("Window is opened....")
- time.sleep(1) #to avoid multiple detection
- except:
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement