Arcade button only works on GPIO pin 3.
This is driving me crazy. I want to use some basic arcade buttons for a project of mine and for some reason they only work on GPIO3.
I've got the raspberry pi 3 v.2 running with raspberry pi os lite.
These are the buttons in question. They come with zero technical details, schematics or anything. Also they have no LEDs or anything requiring additional power.
I put them into my arcade stick and they work as intended. I also bought some quick connect wires for easy wiring.
Here is a picture of the working assembly
It's connected to GPIO3 and ground, which according to several online tutorials is the correct way to wire those buttons. If I put the button on any other GPIO-Pin-Ground combination they don't work.
This is the python code I'm using for my tests.
import RPi.GPIO as GPIO
def button_callback(channel): print("Button was pushed!")
GPIO.setwarnings(True)GPIO.setmode(GPIO.BCM)GPIO.setup(3, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(3,GPIO.RISING,callback=button_callback)
message = input("Press enter to quit\n\n")
GPIO.cleanup()
Here is a screenshot of the console output, with some messages and examples.
Anyone got any idea?
Posted Feb 26, 2021, 11:17 AM UTC · edited
GPIO3 has a pullup resistor because it is one of the I2C interface pins. The other GPIOs don't have the pullup which means the GPIO is forever low as your code sets the pin to pulldown as well.
Either add your own pullup resistor or change your code to say pull_up_down=PUD_UP.
Yesssss!!! Thank you, that worked. Omg, I can finally continue. This was driving me nuts. Thank you very much.