-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathir_sensor.py
More file actions
38 lines (28 loc) · 777 Bytes
/
ir_sensor.py
File metadata and controls
38 lines (28 loc) · 777 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
30
31
32
33
34
35
36
37
38
from picamera import PiCamera
from time import sleep
import RPi.GPIO as GPIO
import time
sensor = 18
camera = PiCamera()
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor,GPIO.IN)
print ("IR Sensor Ready.....")
nr = 0
try:
while True:
if GPIO.input(sensor):
print ("C")
#while GPIO.input(sensor):
#time.sleep(0.02)
else:
print("O")
camera.start_preview()
nr = nr + 1
nrStr = str(nr)
fileName = '/media/pi/INTENSO/video' + nrStr + '.h264'
camera.start_recording(fileName)
sleep(5)
camera.stop_recording()
camera.stop_preview()
except KeyboardInterrupt:
GPIO.cleanup()