Created
October 6, 2020 16:08
-
-
Save suadanwar/5438c89eeff86e7a7d193788b58c960b to your computer and use it in GitHub Desktop.
This sample code is for Raspberry Pi Security Camera with Motion Detector tutorial(image).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import MotionSensor | |
from picamera import PiCamera | |
import time | |
from time import sleep | |
pir = MotionSensor(4) | |
camera = PiCamera() | |
camera.rotation = 180 | |
while True: | |
pir.wait_for_motion() | |
print("Motion detected!") | |
camera.start_preview(fullscreen=False, window = (1250,10,640,480)) | |
filename = "/home/pi/Desktop/" + (time.strftime("%y%b%d_%H:%M:%S")) + ".jpg" | |
camera.capture(filename) | |
pir.wait_for_no_motion() | |
camera.stop_preview() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment