Compare commits
11 Commits
V0.2.2
..
Production
| Author | SHA1 | Date | |
|---|---|---|---|
| 529379ee3b | |||
| 369a64ea98 | |||
| a2152a6cf0 | |||
| b329d8a3f9 | |||
| a6d4a5ae87 | |||
| 5921a64b8f | |||
| 9e83562a5b | |||
| 4d033affa3 | |||
| c3c76f7e7c | |||
| d97bc89d52 | |||
| bf80f9230c |
@@ -2,22 +2,34 @@ import RPi.GPIO as GPIO #Used to Import the LED
|
|||||||
import time #Used to allow wait times
|
import time #Used to allow wait times
|
||||||
from picamera import PiCamera #Used to import the Camera
|
from picamera import PiCamera #Used to import the Camera
|
||||||
from gpiozero import MotionSensor #Used to import the MotionSensor
|
from gpiozero import MotionSensor #Used to import the MotionSensor
|
||||||
|
from datetime import datetime
|
||||||
|
from subprocess import call
|
||||||
import os
|
import os
|
||||||
|
|
||||||
pir = MotionSensor(4)
|
pir = MotionSensor(4)
|
||||||
camera = PiCamera() #Camera Initialization
|
camera = PiCamera() #Camera Initialization
|
||||||
GPIO.setwarnings(False)
|
GPIO.setwarnings(False)
|
||||||
GPIO.setmode(GPIO.BCM) #Setting the GPIO Mode
|
GPIO.setmode(GPIO.BCM) #Setting the GPIO Mode
|
||||||
GPIO.setup(22, GPIO.OUT) #LED output pin
|
GPIO.setup(22, GPIO.OUT) #LED Flash Output
|
||||||
|
GPIO.setup(27, GPIO.OUT) #LED indicator output
|
||||||
|
|
||||||
cwd = os.getcwd() #Sets the Current Working Directory
|
cwd = os.getcwd() #Sets the Current Working Directory
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def bugmotion():
|
def bugmotion():
|
||||||
GPIO.output(22, 0) #Sets light off
|
GPIO.output(22, 0) #Sets light off
|
||||||
|
|
||||||
print("\nProgram Running!")
|
print("\nProgram Running!")
|
||||||
|
for i in range(3):
|
||||||
|
time.sleep(1)
|
||||||
|
GPIO.output(27, 1)
|
||||||
|
time.sleep(1)
|
||||||
|
GPIO.output(27, 0)
|
||||||
|
if i == 3:
|
||||||
|
break
|
||||||
|
|
||||||
|
|
||||||
#To stabilize sensor and Camera
|
#To stabilize sensor and Camera
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
@@ -32,15 +44,21 @@ def bugmotion():
|
|||||||
GPIO.output(22, 1)
|
GPIO.output(22, 1)
|
||||||
|
|
||||||
#Sets Img path and filename, Saves to Working directory of Script
|
#Sets Img path and filename, Saves to Working directory of Script
|
||||||
file_name = cwd + "/Pictures/Capture_" + str(time.time()) + ".jpg"
|
# Grab the current time
|
||||||
print("\nFile Name is: " + file_name)
|
filePath = cwd + "/Pictures/"
|
||||||
|
currentTime = datetime.now()
|
||||||
|
picTime = currentTime.strftime("%Y-%m-%d-%H-%M-%S")
|
||||||
|
picName = "Capture-" + picTime + '.jpg'
|
||||||
|
completeFilePath = filePath + picName
|
||||||
|
#file_name = cwd + "/Pictures/Capture_" + str(time.time()) + ".jpg"
|
||||||
|
print("\nFile Name is: " + completeFilePath)
|
||||||
|
|
||||||
|
|
||||||
#Used to wait for 0.1 Seconds for Camera to be ready
|
#Used to wait for 0.1 Seconds for Camera to be ready
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
|
|
||||||
#Saves File
|
#Saves File
|
||||||
camera.capture(file_name)
|
camera.capture(completeFilePath)
|
||||||
|
|
||||||
#Sets PIR Sensor back to waiting for motion
|
#Sets PIR Sensor back to waiting for motion
|
||||||
print("\nWaiting for no Motion!")
|
print("\nWaiting for no Motion!")
|
||||||
|
|||||||
Reference in New Issue
Block a user