I am using almost all the GPIO pins on a project so I had to be resourceful when adressing the pins for the buttons.
But I just can’t get it to work. I don't know if something is wrong with the code or the wiring, but the buttons don’t work like I want them to. Does something like this even work or am I missing something?
import RPi.GPIO as GPIO import board from signal import pause def my_callback(l, r): if (l == 14 and not(GPIO.input(r))): print("Button 1") elif (l == 14 and GPIO.input(r)): print("Button 2") else: print("Button 3") try: GPIO.setup((14,15), GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.add_event_detect(14, GPIO.FALLING, callback=lambda x : my_callback(14, 15), bouncetime=200) GPIO.add_event_detect(15, GPIO.FALLING, callback=lambda x : my_callback(15, 14), bouncetime=200) pause() except KeyboardInterrupt: GPIO.cleanup()