Button matrix help

Help!
Can anyone help me figure out a good button matrix to be used with an Arduino Leonardo?
Tried searching the forum, but not easy to find. I need 64 buttons, so I was thinking a 18x7 grid but some part don't have buttons, so a little tricky....

:thinking:

I have seen a few libraries for that. You need to search better.

The logical matrix doesn't need to match the physical layout. I don't really see any advantage in doing so, unless it's something to do with your inter-button wiring. You could use an 8x8 matrix.

1 Like

Depending on what features you want, it could be something as simple as this. I'm no expert on button matrices, that link is just some very simple example code I wrote to help someone in that topic. If you need to do anything other than detect buttons opening and closing, then it might be worth looking at more sophisticated examples.

1 Like

I want to create a button box with 64 buttons (2 pins on each) to work as a "game controller or HID".

If I create a 8x8 matrix I don't understand how I can connect 16 pins to the Arduino...?

Did you look at the specs of the Leonardo? How many input/output pins does it have?

1 Like

I just found out that it has 20 digital inputs/outputs :+1:
First when I read the docs I only saw D0-D13 and missed that A0-A5 can be used for digital as well :slight_smile:

Thanks for the note @PaulRB !

Exactly. So you have more pins than you need, which means you can choose other matrix sizes which could be more convenient for you than cramming your buttons into an 8x8 matrix. For example a 6x12 or 7x12 matrix might be more convenient, if a little less efficient.

Note: if any of these buttons are not momentary (like toggle switches or latching buttons, or if you plan to hold some of them down while pressing others, like a shift or control key) you will need to add some diodes to your matrix also.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.