This is the code:
#!/usr/bin/python3
from time import sleep
from gpiozero import LED, Button
from threading import Thread
from signal import pause, signal, SIGTERM
LEDs = [5, 17, 22, 19, 26]
LIGHTS = [LED(LEDs[0]), LED(LEDs[1]), LED(LEDs[2]), LED(LEDs[3]), LED(LEDs[4])]
pushButton = Button(21)
DELAY = 0.5
def cleanup(signum, frame):
exit(2)
# TODO: Create a button callback function which will change blinking speed
def buttonLEDs():
global DELAY
while True:
if pushButton.is_pressed:
print("Click")
DELAY += 0.1
def LEDseq():
while True:
for LED in LIGHTS:
LED.on()
sleep(DELAY)
LED.off()
for LED in reversed(LIGHTS):
LED.on()
sleep(DELAY)
LED.off()
try:
signal(SIGTERM, cleanup)
# pushButton = buttonControl
# pushButton.when_pressed = LEDseq
LEDseq()
# buttonControl(LEDseq)
pause()
except KeyboardInterrupt:
exit(1)
I'm trying to make a callback function for a button that would change the sleep interval of LEDseq
when the button is pressed so I created this function:
but it doesn't seem to work. Any idea why?
print
inside the if ... is_pressed as I also updated my question with a full. Check it out. And thank you for your response – MrYosuko Apr 5 '20 at 13:32flashLED()
that was supposed to be LEDseq that I've forgotten to rename – MrYosuko Apr 5 '20 at 13:49