diff --git a/Relays/run.sh b/Relays/run.sh new file mode 100755 index 0000000..92844ed --- /dev/null +++ b/Relays/run.sh @@ -0,0 +1,2 @@ +#!/bin/bash +sudo python script.py diff --git a/Relays/script.py b/Relays/script.py index e82b7d4..9624570 100644 --- a/Relays/script.py +++ b/Relays/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 +