Update main.py
This commit is contained in:
23
main.py
23
main.py
@@ -1,12 +1,12 @@
|
|||||||
import RPi.GPIO as GPIO #Used to Import the LED
|
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 datetime import datetime
|
from datetime import datetime
|
||||||
from subprocess import call
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
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
|
||||||
@@ -31,15 +31,10 @@ def bugmotion():
|
|||||||
break
|
break
|
||||||
|
|
||||||
|
|
||||||
#To stabilize sensor and Camera
|
#To stabilize the Camera
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
while True:
|
while True:
|
||||||
|
|
||||||
#Waits for Motion from PIR Sensor
|
|
||||||
pir.wait_for_motion()
|
|
||||||
|
|
||||||
print("\nBug detected")
|
|
||||||
|
|
||||||
#Turns on the LED Flash
|
#Turns on the LED Flash
|
||||||
GPIO.output(22, 1)
|
GPIO.output(22, 1)
|
||||||
|
|
||||||
@@ -60,19 +55,15 @@ def bugmotion():
|
|||||||
#Saves File
|
#Saves File
|
||||||
camera.capture(completeFilePath)
|
camera.capture(completeFilePath)
|
||||||
|
|
||||||
#Sets PIR Sensor back to waiting for motion
|
|
||||||
print("\nWaiting for no Motion!")
|
|
||||||
pir.wait_for_no_motion()
|
|
||||||
|
|
||||||
#Used to turn off the LED after 0.2 Secs
|
#Used to turn off the LED after 0.2 Secs
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
|
||||||
#Used to turn off the LED
|
#Used to turn off the LED
|
||||||
GPIO.output(22, 0)
|
GPIO.output(22, 0)
|
||||||
|
|
||||||
#Used to stabilize Sensor and allow the Camera to refocus
|
#Used to wait 5 minutes for camera to take a photo
|
||||||
time.sleep(2)
|
time.sleep(300)
|
||||||
print("\nSystem Ready!")
|
print("\nTaking photo!")
|
||||||
|
|
||||||
def exit_handler():
|
def exit_handler():
|
||||||
print('Program Shutting Down!')
|
print('Program Shutting Down!')
|
||||||
|
|||||||
Reference in New Issue
Block a user