From 5aed2d580ba5292f3b2d5349202c3f6628d2a246 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Sat, 22 Feb 2020 18:05:01 +0000 Subject: [PATCH] Push buttons work --- Relays/script.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Relays/script.py diff --git a/Relays/script.py b/Relays/script.py new file mode 100644 index 0000000..e82b7d4 --- /dev/null +++ b/Relays/script.py @@ -0,0 +1,35 @@ +import RPi.GPIO as GPIO + + +PUSH = [ +21, #1 +20, #2 +16, #3 +26 #4 +] + + +RELAYS = [ +[], #1 +[], #2 +[], #3 +[] #4 +] + +# Initialize +GPIO.setmode(GPIO.BCM) + +# Push buttons +for i in PUSH: + print("Init push button: " + str(i)) + GPIO.setup(i, GPIO.IN, pull_up_down=GPIO.PUD_UP) + + + +# Infinite loop +while True: + + for num in range(0, len(PUSH)): + + if GPIO.input(PUSH[num]) == False: + print("Button " + str(num) + " pressed")