Control first relay

This commit is contained in:
Pierre HUBERT 2020-02-22 18:23:12 +00:00
parent 9001616c84
commit 76df3ee825
2 changed files with 18 additions and 1 deletions

2
Relays/run.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/bash
sudo python script.py

View File

@ -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