forked from sakearzoo/Advanced-Motion-Detection-System
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpirCamera.py
More file actions
29 lines (23 loc) · 644 Bytes
/
pirCamera.py
File metadata and controls
29 lines (23 loc) · 644 Bytes
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
#!/usr/bin/python
#https://github.com/sakearzoo
#By Sheikh Nawab Arzoo
import RPi.GPIO as GPIO
import time
import picamera # new
sensorPin = 7
GPIO.setmode(GPIO.BOARD)
GPIO.setup(sensorPin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
prevState = False
currState = False
cam = picamera.PiCamera() # new
while True:
time.sleep(0.1)
prevState = currState
currState = GPIO.input(sensorPin)
if currState != prevState:
newState = "HIGH" if currState else "LOW"
print "GPIO pin %s is %s" % (sensorPin, newState)
if currState: # new
cam.start_preview()
else:
cam.stop_preview()