-
Notifications
You must be signed in to change notification settings - Fork 1
/
readYear.py
72 lines (52 loc) · 1.57 KB
/
readYear.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import Adafruit_BBIO.GPIO as gpio
from time import sleep
from collections import OrderedDict as od
def setup_pin_list(start, stop):
pins = []
pins = ['P9_14', 'P9_16', 'P8_08', 'P8_09', 'P8_11', 'P8_12', 'P8_13', 'P8_14', 'P8_15', 'P8_16', 'P8_17']
print(pins)
return pins
def setPinsGPIOin(pins):
pinDict = od()
for pin in pins:
gpio.setup(pin, gpio.IN)
pinDict[str(pin)] = str(gpio.input(pin))
print pinDict
def check_all(pins):
pinDict = od()
for pin in pins:
pinDict[pin] = gpio.input(pin)
print pinDict
def checkCycle(pins):
count = 0
pinDict = od()
running = True
while running == True:
for pin in pins:
pinDict[pin] = gpio.input(pin)
#print pinDict
values = []
for pin,value in pinDict.items():
values.append(pinDict[pin])
reverse_values = values[::-1]
if count%2 == 0:
print('L->H' + str(values) + " = " + str(int(''.join(str(int(value)) for value in values), 2)))
#print('H->L' + str(reverse_values) + " = " + str(int(''.join(str(int(value)) for value in reverse_values), 2)))
count += 1
if count%2 == 0:
userInput = raw_input('continue?')
if userInput == 'n':
running = False
else:
running = True
def main():
pins = setup_pin_list(8,18)
setPinsGPIOin(pins)
input = raw_input('check?')
if input == 'y':
pass
else:
exit()
checkCycle(pins)
if __name__ == "__main__":
main()