-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathall_valves_on.py
69 lines (55 loc) · 1.31 KB
/
all_valves_on.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
from time import sleep
import RPi.GPIO as GPIO
import math
NUM_VALVES = 23
def main():
print("Main running")
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
# rpi skips gpio 1, 14, 15, 22
ioMap = {}
ioMap[0] = 2
ioMap[1] = 3
ioMap[2] = 4
ioMap[3] = 17
ioMap[4] = 27
ioMap[5] = 22
ioMap[6] = 10
ioMap[7] = 9
ioMap[8] = 11
ioMap[9] = 0
ioMap[10] = 5
ioMap[11] = 6
ioMap[12] = 13 #Sounds funny
ioMap[13] = 19
ioMap[14] = 26
ioMap[15] = 14
ioMap[16] = 15
ioMap[17] = 18
ioMap[18] = 23
ioMap[19] = 24
ioMap[20] = 25
ioMap[21] = 8
ioMap[22] = 7
button = 1
button2 = 12
# put your setup code here, to run once:
for i in range(NUM_VALVES):
# print("setup: ", i)
GPIO.setup(ioMap[i], GPIO.OUT)
for j in range(NUM_VALVES):
GPIO.output(ioMap[j], GPIO.LOW);
sleep(1)
while (True):
for j in range(NUM_VALVES):
print("Testing: ", j)
GPIO.output(ioMap[j], GPIO.HIGH)
sleep(0.75)
GPIO.output(ioMap[j], GPIO.LOW)
sleep(0.75)
# for j in range(NUM_VALVES):
# GPIO.output(j, GPIO.LOW)
sleep(5)
print("DONE")
#Actually run this code
main()