-
Notifications
You must be signed in to change notification settings - Fork 0
/
motion_cam.py
48 lines (44 loc) · 1.04 KB
/
motion_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
41
42
43
44
45
46
47
48
import time
import picamera
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.IN)
GPIO.setup(18, GPIO.OUT)
GPIO.output(18, False)
while True:
if(GPIO.input(23) == 1):
print "motion"
GPIO.output(18, True)
with picamera.PiCamera() as camera:
# Turn the camera's LED off
camera.led = False
# Take video
camera.resolution = (1280, 720)
filename = 'video%02d.h264' % i
camera.start_recording(filename)
while(GPIO.input(23) == 1):
camera.wait_recording(5)
camera.stop_recording()
i = i + 1
elif(GPIO.input(23) == 0):
print "no motion"
GPIO.output(18, False)
#
#
# import time
# import picamera
# import RPi.GPIO as GPIO
#
# GPIO.setmode(GPIO.BCM)
# GPIO.setup(23, GPIO.IN)
# GPIO.setup(18, GPIO.OUT)
#
# while True:
# if(GPIO.input(23) == 1):
# print "motion"
# GPIO.output(18, True)
# elif(GPIO.input(23) == 0):
# print "no motion"
# GPIO.output(18, False)
#
#