Raspberry Pi Based Security System | CAMERA | PIR Motion Sensor
Raspberry Pi Based Security System | CAMERA | PIR Motion Sensor
Code:-
Appendix - PIR Code
from gpiozero import MotionSensor
from gpiozero import Buzzer
from picamera import PiCamera
from datetime import datetime
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
buzzer_pin = 24
led_pin = 18
GPIO.setup(24, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
camera = PiCamera()
pir = MotionSensor(4)
while True:
pir.wait_for_motion()
filename = datetime.now().strftime("%Y-%m-%d_%H.%M.%S.image.jpg")
camera.capture (filename)
GPIO.output(buzzer_pin, True)
GPIO.output(led_pin, True)
sleep(1)
GPIO.output(buzzer_pin, False)
pir.wait_for_no_motion()
GPIO.output(led_pin, False)
GPIO.output(buzzer_pin, True)
sleep(1)
GPIO.output(buzzer_pin, False)
No comments