From bf80f9230cc0f6b9dcc5ee6e2acfe93bfc1857cb Mon Sep 17 00:00:00 2001 From: Jordan-Fielding <107819004+Jordan-Fielding@users.noreply.github.com> Date: Thu, 7 Jul 2022 15:11:29 +1000 Subject: [PATCH] Update main.py --- main.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 0eb0153..7f31ca4 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,8 @@ import RPi.GPIO as GPIO #Used to Import the LED import time #Used to allow wait times from picamera import PiCamera #Used to import the Camera from gpiozero import MotionSensor #Used to import the MotionSensor +from datetime import datetime +from subprocess import call import os pir = MotionSensor(4) @@ -14,6 +16,7 @@ cwd = os.getcwd() #Sets the Current Working Directory + def bugmotion(): GPIO.output(22, 0) #Sets light off @@ -32,6 +35,11 @@ def bugmotion(): GPIO.output(22, 1) #Sets Img path and filename, Saves to Working directory of Script + # Grab the current time + currentTime = datetime.now() + picTime = currentTime.strftime("%Y.%m.%d-%H%M%S") + picName = picTime + '.jpg' + completeFilePath = filePath + picName file_name = cwd + "/Pictures/Capture_" + str(time.time()) + ".jpg" print("\nFile Name is: " + file_name) @@ -40,7 +48,7 @@ def bugmotion(): time.sleep(0.1) #Saves File - camera.capture(file_name) + camera.capture(completeFilePath) #Sets PIR Sensor back to waiting for motion print("\nWaiting for no Motion!")