-
Notifications
You must be signed in to change notification settings - Fork 0
/
timingTest.py
35 lines (29 loc) · 1020 Bytes
/
timingTest.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
#!/usr/bin/env python
#import sys
#sys.path.append('/home/pi/Desktop/Programs/Sensor Files/sensorFunctions.py')
import sensorFunctions
import RPi.GPIO as GPIO
import time
lightRELAY = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(lightRELAY, GPIO.OUT)
while True:
#loop through 0.5 second delay 101 times, 30.5 seconds
for i in range(0, 100):
print "Reading Phototransistor"
phototransValue = sensorFunctions.readPhototransistor(0)
print "Phototransistor Read: ", phototransValue
lumens = sensorFunctions.convertToLumens(phototransValue)
print "Analog Converted to Lumens: ", lumens
if (lumens > 700):
print "KEEP RELAYS ON, COUNT: ", i
GPIO.output(lightRELAY, True)
time.sleep(0.5)
else:
print "ERROR, TIME NOT EXPIRED, RELAYS OFF?"
print ""
print "ABORTING OPERATION"
break
print "DONE, TURNING OFF RELAYS"
GPIO.output(lightRELAY, False)
time.sleep(10)