How to - Use the GPIO for Buttons instead of a Teensy

Various user-contributed guides for hardware-related things
User avatar
m0rphman
Posts: 22
Joined: Tue May 10, 2016 10:17 am
Has thanked: 1 time
Been thanked: 3 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by m0rphman » Thu Jul 07, 2016 3:51 am

Hi so I've done everything as outlined in this tutorial, but for some reason I can't get my button presses to work. I've checked current with DMM and It seems I'm properly grounded. I'm using a slightly different pin setup for testing at this point, I am using physical pin 39 for the ground and 40 to test with the left button. EmulationStation however only recognizes the button if I touch the wire to the contact, and not if the contact is soldered and then the button is pressed. Any ideas why this would be?

Just a little more information, I'm using the kitsch-bent expanded common ground pcb and 40-pin gpio cable so I don't have to solder to the gpio pins. Any help would be much appreciated!!
Maybe the the resistance between the GPIO and GND pin is too high because the connection on your button board so too weakly closed by your button press? In my setup for example, I drilled the holes for the X and Y buttons slightly off center, so if I press one of those buttons only a small part of the contact pad is bridged. I connected an LED to check the connection and I found that the LED is dimmer when I use the X or Y button compared to any other button which are more well centered.
Do you have this problem with all buttons or just the left button?

Also I have a general question about using the GPIO pins for input. Is it still possible to connect an external controller via USB or do I have to change the input configuration in emulationstation everytime I want to use either the GB buttons or the external controller?

Thanks
m0rphman

User avatar
winnetouch
Posts: 158
Joined: Mon Jul 11, 2016 10:56 am
Has thanked: 2 times
Been thanked: 30 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by winnetouch » Mon Jul 11, 2016 11:03 am

I'm trying this on a raspberry pi zero to use with retropie. But it seems the 10-retrogame.rules is never generated no mater how many times I make the retrogame files. Is anyone else gaving issues with that? After I type the make retrogame command I get this returned:

Code: Select all

gcc  -Wall -O3 -fomit-frame-pointer -funroll-loops -s retrogame.c -o retrogame
strip retrogame

User avatar
m0rphman
Posts: 22
Joined: Tue May 10, 2016 10:17 am
Has thanked: 1 time
Been thanked: 3 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by m0rphman » Mon Jul 11, 2016 1:32 pm

I'm trying this on a raspberry pi zero to use with retropie. But it seems the 10-retrogame.rules is never generated no mater how many times I make the retrogame files. Is anyone else gaving issues with that? After I type the make retrogame command I get this returned:
When you use the

Code: Select all

make retrogame

command that does not automatically create the 10-retrogame.rules file. In order to do that you have to run the code prerunnerseth posted:
To add the rule, run the following command to create and edit the file /etc/udev/rules.d/10-retrogame.rules in the nano text editor:

Code: Select all

sudo nano /etc/udev/rules.d/10-retrogame.rules

Now copy in the following line exactly as shown (this should all be on a single line in the rules file, i.e. don't put in any linebreaks):

Code: Select all

SUBSYSTEM=="input", ATTRS{name}=="retrogame", ENV{ID_INPUT_KEYBOARD}="1"

Save the file by pressing Ctrl-O and pressing enter, then exit nano by pressing Ctrl-X. Restart your Raspberry Pi to make sure the new configuration is loaded.
Now we’re in good shape to test it!
Good Luck :)

Racerboy
Posts: 129
Joined: Thu Jun 02, 2016 4:49 pm
Has thanked: 25 times
Been thanked: 36 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by Racerboy » Sun Jul 24, 2016 5:26 pm

I keep getting this error when I input the "sudo ./retrogame" command:

Code: Select all

./retrogame: Pin config failed. Try 'sudo ./retrogame'.
Anyone know why? Pretty sure I did all the steps correctly.

Racerboy
Posts: 129
Joined: Thu Jun 02, 2016 4:49 pm
Has thanked: 25 times
Been thanked: 36 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by Racerboy » Mon Jul 25, 2016 4:20 pm

Oh, my pin 23 is being taken up by my TFT display (temporary...), and it won't allow it to configure (not sure why?)

Is there a workaround for this?

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by prerunnerseth » Thu Jul 28, 2016 5:29 am

Racerboy wrote:Oh, my pin 23 is being taken up by my TFT display (temporary...), and it won't allow it to configure (not sure why?)

Is there a workaround for this?
If your TFT is using the pin then it cant be configured for something else. You can change the code in the retrogame.c file to configure it to use another available pin.

Racerboy
Posts: 129
Joined: Thu Jun 02, 2016 4:49 pm
Has thanked: 25 times
Been thanked: 36 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by Racerboy » Thu Jul 28, 2016 9:15 am

prerunnerseth wrote:
Racerboy wrote:Oh, my pin 23 is being taken up by my TFT display (temporary...), and it won't allow it to configure (not sure why?)

Is there a workaround for this?
If your TFT is using the pin then it cant be configured for something else. You can change the code in the retrogame.c file to configure it to use another available pin.
I'm just confused because these are the pins that my TFT display takes up (boxed in red):

Image

Unless I'm missing something, none of which are used in the retrogame.c file.

Does the "input" column in the pin/key table mean the pin # or the BCM #?

prerunnerseth
Posts: 279
Joined: Fri May 06, 2016 5:36 pm
Has thanked: 16 times
Been thanked: 229 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by prerunnerseth » Thu Jul 28, 2016 9:27 am

Racerboy wrote:
prerunnerseth wrote:
Racerboy wrote:Oh, my pin 23 is being taken up by my TFT display (temporary...), and it won't allow it to configure (not sure why?)

Is there a workaround for this?
If your TFT is using the pin then it cant be configured for something else. You can change the code in the retrogame.c file to configure it to use another available pin.
I'm just confused because these are the pins that my TFT display takes up (boxed in red):

Image

Unless I'm missing something, none of which are used in the retrogame.c file.

Does the "input" column in the pin/key table mean the pin # or the BCM #?
BCM #

Racerboy
Posts: 129
Joined: Thu Jun 02, 2016 4:49 pm
Has thanked: 25 times
Been thanked: 36 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by Racerboy » Fri Jul 29, 2016 12:42 pm

Edit: See below
Last edited by Racerboy on Sat Jul 30, 2016 8:25 pm, edited 1 time in total.

Racerboy
Posts: 129
Joined: Thu Jun 02, 2016 4:49 pm
Has thanked: 25 times
Been thanked: 36 times

Re: How to - Use the GPIO for Buttons instead of a Teensy

Post by Racerboy » Sat Jul 30, 2016 8:24 pm

Image

@prerunnerseth So it can't configure pin 23, which is BCM 11 (SCLK), which is being used by my display. But I'm not sure why that matters because in the retrogame.c code, BCM 11 isn't even referenced, and that pin shouldn't even be used by retrogame.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest