Control first relay
This commit is contained in:
parent
9001616c84
commit
76df3ee825
2
Relays/run.sh
Executable file
2
Relays/run.sh
Executable file
@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
sudo python script.py
|
@ -10,7 +10,7 @@ PUSH = [
|
||||
|
||||
|
||||
RELAYS = [
|
||||
[], #1
|
||||
[14], #1
|
||||
[], #2
|
||||
[], #3
|
||||
[] #4
|
||||
@ -26,6 +26,15 @@ for i in PUSH:
|
||||
|
||||
|
||||
|
||||
# Relays
|
||||
for i in RELAYS:
|
||||
for j in i:
|
||||
print("Init relay: "+str(j))
|
||||
GPIO.setup(j, GPIO.OUT)
|
||||
GPIO.output(j, True)
|
||||
|
||||
|
||||
|
||||
# Infinite loop
|
||||
while True:
|
||||
|
||||
@ -33,3 +42,9 @@ while True:
|
||||
|
||||
if GPIO.input(PUSH[num]) == False:
|
||||
print("Button " + str(num) + " pressed")
|
||||
|
||||
for curr in range(0, len(PUSH)):
|
||||
|
||||
for id_relay in RELAYS[curr]:
|
||||
GPIO.output(id_relay, curr != num) # Inverted condition
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user