Last active
October 6, 2020 16:08
-
-
Save suadanwar/47c64949113f1d0577fe2b032789bd6e to your computer and use it in GitHub Desktop.
This sample code is for Raspberry Pi Security Camera with Motion Detector tutorial.
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")) + ".h264" | |
camera.start_recording(filename) | |
pir.wait_for_no_motion() | |
camera.stop_recording() | |
camera.stop_preview() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment