Buttons not working?

Need some help with your shiny new breakout board, or something not working right? Let us help you here!
Post Reply
SunnyNomad
n00b
Posts: 6
Joined: Sun May 13, 2018 9:34 am

Buttons not working?

Post by SunnyNomad » Sun May 13, 2018 9:44 am

Hi guy's.

I recently bought a few 30mm translucent arcade buttons from the site with the quick connect cables to work with my new Pi b+. I'm running an omxplayer looking to setup a small mp3 player for a small non profit arts event this summer. I've got my setup working fine with my breadboard and small pin push buttons from canakit but when trying to use the arcade buttons wired directly to my GPIO pins i get nothing. It looks like my app maye registering the buttons being connected but when pressing the buttons nothing happens. Oddly once or maybe twice out of say 50 presses one or two buttons worked once. I've tried all 3 buttons i've purchased and 4 or 5 different quick connect wires. Any idea what could be the issue?

Cheers.

Here's my log from Debug:

DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0

User avatar
Dave
ModMyPi
Posts: 2649
Joined: Wed Jul 22, 2015 11:36 am
Contact:

Re: Buttons not working?

Post by Dave » Mon May 14, 2018 8:44 am

How are you wiring up the buttons directly to the GPIO header?

Usually 1 pin of the button would go to your GPIO pin that you are monitoring high/low values, and the other pin would go to 3v3 or GND, depending if you want the single to go high or low when you press the button.

You'll also probably want to use a pull-up or pull-down resistor (unless you are doing this in your code) and there's no harm including a current limiting resistor to make sure you don't damage the GPIO pin.

If you could post a picture of the wiring, and maybe a snippet from the code I'll see what I can suggest.
Forum Administrator & Technical Support

SunnyNomad
n00b
Posts: 6
Joined: Sun May 13, 2018 9:34 am

Re: Buttons not working?

Post by SunnyNomad » Mon May 14, 2018 9:43 am

So the update today is i believe it is the quick connect wires i have been sold. Or the way they connect directly to the GPIO pins. I was getting nowhere using the buttons directly to the GPIO via these quick connect wires. I would only get the following in the DEBUG:

DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Next: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0
DEBUG:__Button__:Play: Edge detected 0=>0


Oddly maybe one of of 50 tries i would get a result button pressed.

DEBUG:__Button__:Play: Edge detected 0=>1
DEBUG:__Button__:Play: pressed!


This was very intermitent suggesting a loose wire maybe or some sort of short. So to rule out the buttons i wired them up to my breadboard as i know this worked with my basic push buttons and hey presto they work fine.

So to summarise. My arcade buttons work via the breadboard using the ribbon cable to my GPIO. They do not work using the quick connect wires directly to the GPIO. I've attached a couple of photos to show but it's a shame as my design would have looked nice and tidy using the quick connect cables and no soldering needed. I'm going to go back to the manufacturer to see what they say... Unless i'm missing something really obvious it looks to be them. I bought a pack of ten and none of them work. Odd.

Pics attached.
Pic 1: Arcade button > quick connect cable > GPIO - This does not work currently.

Pic2: Arcade button > breadboard > ribbon/GPIO - Works fine.

Pic3: Push button > breadboard > ribbon/GPIO - Works fine.

The code i'm using is from here. SO far so good and it works great with the wiring that does work.

https://github.com/jehutting/omxplayer-player

SunnyNomad
n00b
Posts: 6
Joined: Sun May 13, 2018 9:34 am

Re: Buttons not working?

Post by SunnyNomad » Mon May 14, 2018 9:45 am

Tried to attach a few jpegs but it says my images are invalid. No idea why??

SunnyNomad
n00b
Posts: 6
Joined: Sun May 13, 2018 9:34 am

Re: Buttons not working?

Post by SunnyNomad » Mon May 14, 2018 10:26 am

Update. I have another type of jumper wire i've just used to go directly from the buttons to the gpio. This also doesn't work. It appears that the only way i can get this to work is by going via the breadoboard / ribbon cable. Anything directly to the GPIO pins doesn't fire.

SunnyNomad
n00b
Posts: 6
Joined: Sun May 13, 2018 9:34 am

Re: Buttons not working?

Post by SunnyNomad » Mon May 14, 2018 10:51 am

Update. I've wired my arcade button directly to the gpio using male / female jumper wires. This time i wired to the 3.3v and the other to gpio25 which is my play / pause button. This works. I thought the gpio25 would be providing power? Also, how then do these quick connect wires work as they are instructed to go to gpio x and grnd?

SunnyNomad
n00b
Posts: 6
Joined: Sun May 13, 2018 9:34 am

Re: Buttons not working?

Post by SunnyNomad » Mon May 14, 2018 11:49 am

Hi all.

FYI for anyone having a similar issue. I had to change the code to GPIO.PUD_UP as the quick connect wires go to GPIO pin and GND. The code was originally set to GPIO.PUD_DOWN which is why my tests only worked when wired to GPIO pin and 3.3v.

I'm new to all of this so it took a little time and testing. : )

User avatar
Dave
ModMyPi
Posts: 2649
Joined: Wed Jul 22, 2015 11:36 am
Contact:

Re: Buttons not working?

Post by Dave » Mon May 14, 2018 4:26 pm

GPIO pins need to be configured as an input or an output.

Typically 1 pin of your button will be connected to your signal GPIO pin, and the other pin connected to either 3v3 or 0v (ground). When you press the button, the signal GPIO pin is connected to 3v3 or 0v, and the input is set high or low, respectively.

When the button is not being pressed you have a "floating" state, which means it is neither high or low. This is why you need a pull-up or pull-down resistor to ensure the input has a set state. If your code is looking for a high signal, then you use a pull-down resistor, If your code is looking for a low signal, you use a pull-up resistor.
Forum Administrator & Technical Support

Post Reply