-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCam.py
40 lines (33 loc) · 1.1 KB
/
Cam.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from gpiozero import LightSensor, Buzzer, LED
from picamera import PiCamera
from time import sleep
from email.mime.image import MIMEImage
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import smtplib
import datetime
import time
ldr = LightSensor(4) # alter if using a different pin
buzzer = Buzzer(17) # alter if using a different pin
led = LED(18)
camera = PiCamera()
while True:
sleep(0.1)
led.off()
if ldr.value < 0.5: # adjust this to make the circuit more or less sensitive
buzzer.on()
led.on()
camera.resolution = (2592,1944)
camera.framerate = 15
Captured1='/home/pi/Desktop/image'+datetime.datetime.now().strftime('%Y-%m-%d%H:%M:%S') + '.png'
camera.rotation = 180
camera.capture(Captured1)
buzzer.off()
led.off()
Captured2='/home/pi/Desktop/image'+datetime.datetime.now().strftime('%Y-%m-%d%H:%M:%S') + '.png'
camera.rotation = 180
camera.capture(Captured2)
print('Image Captured')
else:
buzzer.off()
led.off()