So, I have 2 buttons set up on pins 17 and 27.
buttons = (17, 27) GPIO.setup(buttons, GPIO.IN, pull_up_down=GPIO.PUD_UP)
I need to accept input from EITHER of these for a set period of time.
I found this code which works for 1 button here
channel = GPIO.wait_for_edge(17, GPIO_RISING, timeout=5000) if channel is None: print('Timeout occurred') else: print('Edge detected on channel', channel)
I changed "GPIO_RISING" to "GPIO.RISING" to get it to work.
As mentioned this works fine for 1 button, and can detect the button press. The problem is when I try and alter the code to accept the second button.
channel = GPIO.wait_for_edge(17, GPIO.RISING, timeout=5000) channel1 = GPIO.wait_for_edge(27, GPIO.RISING, timeout=5000) if channel is None and channel1 is None : print('Timeout occurred') elif channel is not None: print('Edge detected on channel', channel) elif channel1 is not None: print('Edge detected on channel', channel1) else: print('something')
This makes channel detectable for the first 5 seconds and channel1 detectable the next 5 seconds, not concurrently.
How do I solve this?