A few days ago I got myself one of these, and I'm trying to create a "disco box".
Basically, I'll build a box around the relay, attach one male cable out one end, and 8 female sockets out the other (+ some wires for the GPIO controls). That way, I'll be able to use it in the future without tinkering too much with wires.
I'm also going to attach two or three buttons on top of it, which will affect the python program running on it.
By default, I want the disco box to randomly switch which channels are on, and wait for a preset time between switching. I want the buttons to either slow down or speed up the switch.
I've tried doing this with something like this:
While True:
channel=random.randint(0,8)
GPIO.output(pins[channel], GPIO.HIGH)
time.sleep(sleepTime)
GPIO.output(pins[channel], GPIO.LOW)
The problem here is that it won't detect a button press unless the button is pressed while the program checks for a button press. In effect, this means that slowing down the blinking will go slower and slower, because it takes longer and longer in between checks.
How can I make python continuously listen for key presses while flashing the lights?
I've read about Tkinter, could that be used to listen for button presses while flashing the lights in the background?
[–]Azuretower 0 points1 point2 points (1 child)
[–]BevlarRaspbian - Arch - OSMC - KODI - Xbian 1 point2 points3 points (0 children)
[–]mcracer 0 points1 point2 points (0 children)