Push buttons work
This commit is contained in:
parent
9794521fc0
commit
5aed2d580b
35
Relays/script.py
Normal file
35
Relays/script.py
Normal file
@ -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")
|
Loading…
Reference in New Issue
Block a user