12 buttons with only 4 GPIO pins

General GBZ-related chat goes here. Share ideas, tips and tricks, or ask questions that don't fit into the hardware/software help forums.
Post Reply
User avatar
1461748123
Posts: 143
Joined: Wed May 04, 2016 8:36 pm
Has thanked: 9 times
Been thanked: 17 times

12 buttons with only 4 GPIO pins

Post by 1461748123 » Sun Jun 05, 2016 11:55 am

Hello guys! :)

I've decided to use DPI to drive the screen and use 2 PWM pins to output audio, these take up almost all of the GPIO pins and left with only 4 for me to use. I've to figure out a way to control 12 buttons in total with only 4 GPIO pins, otherwise, I've to use teensy and sacrifice an USB port. ;)

@kite linked me to this project call gamegirl: https://hackaday.io/project/10207-gameg ... done-right

They use a very clever way to achieve what I'm looking for, controlling 12 buttons with 4 I/O pins! After doing some research I found out the method they are using is call charliplexing.
Image

How this work is, it will set one pin as output and the other three as input, and then loop through all the pins. Each time a output can only get maximum of 3 inputs. We can set total of 4 pins as output so we can get maximun of 3x4 = 12 inputs.

But, the schematics they provided have some problems, they use one diode for each 3 buttons. This means, if multiple buttons are pushed, it will create false input there for create something call "ghosting".
I improve the schem by adding diode to each button, and the next step will be testing the setup and create a scrip to drive the whole thing. I will post my progress here as well as my build log :)
Image

User avatar
Helder
Trailblazer
Trailblazer
Posts: 2887
Joined: Thu May 05, 2016 8:33 am
Location: Rogers, AR
Has thanked: 1436 times
Been thanked: 3096 times

Re: 12 buttons with only 4 GPIO pins

Post by Helder » Sun Jun 05, 2016 12:12 pm

What improvements did you make in the schematic? The one you made looks exactly like the one above. Maybe you forgot to edit it with the diodes? If I'm reading this right each button will get a diode so 12 in total instead of the 4 currently in the schematic.
My Sale Threads:

Retro PSU, 3.5A output!


Chat with me and other members


Don't contact me about obtaining my board files (as you will not get them). Don't contact me about any of my boards if they are sold out, they will be restocked as soon as I can get them.


Don't support thieves like ckliang who copied my AIO to resell and is now cloning the mintyPi, support the original creators and not the thieves!

User avatar
1461748123
Posts: 143
Joined: Wed May 04, 2016 8:36 pm
Has thanked: 9 times
Been thanked: 17 times

Re: 12 buttons with only 4 GPIO pins

Post by 1461748123 » Sun Jun 05, 2016 12:13 pm

Helder wrote:What improvements did you make in the schematic? The one you made looks exactly like the one above. Maybe you forgot to edit it with the diodes? If I'm reading this right each button will get a diode so 12 in total instead of the 4 currently in the schematic.
ops wrong image :D will fix it now

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest