36 lines
418 B
Python
36 lines
418 B
Python
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")
|