How does a key matrix handle missing physical buttons?

Hi All,

I am making a panel for a flight sim and have 19 physical buttons. I have been trying to adapt a sketch that has a 5x5 key matrix.

I have sketched a schematic for the matrix and tried with 19 buttons but it doesn't seem to be working.

Here are snippets of the code that I think are relevant to the matrix.

#define ENABLE_PULLUPS
#define NUMROTARIES 5
#define NUMBUTTONS 19
#define NUMROWS 5
#define NUMCOLS 5


byte buttons[NUMROWS][NUMCOLS] = {
  {1,9,6,18},
  {3,11,14,15},
  {2,10,13,17,19},
  {4,12,7,16},
  {8,5},
};

byte rowPins[NUMROWS] = {10,11,12,13,A0}; 
byte colPins[NUMCOLS] = {A5,A4,A3,A2,A1};

My schematic is as follows:

Does that matrix look correct with regards to the fact I have missing physical keys ?

No problem beause they are never pressed and therefore will never indicate!
Arrange Your buttons to 4 x 5, 4 rows and 5 columns, and You can save one I/O pin.

Railroader:
No problem beause they are never pressed and therefore will never indicate!
Arrange Your buttons to 4 x 5, 4 rows and 5 columns, and You can save one I/O pin.

Great thanks for your reply. I will have a look at doing a 4 x 5 as you suggest :slight_smile:

Thanks!

Keep in mind that a Matrix Keypad has many more buttons than one would initially think! If you use your 5x5 keypad as a 4x5 keypad you will have many more than 20 button options, most people forget that you can have multiple button presses at once.

Research "Matrix Keypad" and "Ghosting", Ghosting can be totally eliminated with the addition of Diodes on the keypad layout! To save you a little work and prevent confusion here is an article that may be helpful "https://www.baldengineer.com/arduino-keyboard-matrix-tutorial.html"

japreja:
Keep in mind that a Matrix Keypad has many more buttons than one would initially think! If you use your 5x5 keypad as a 4x5 keypad you will have many more than 20 button options, most people forget that you can have multiple button presses at once.

Research "Matrix Keypad" and "Ghosting", Ghosting can be totally eliminated with the addition of Diodes on the keypad layout! To save you a little work and prevent confusion here is an article that may be helpful "https://www.baldengineer.com/arduino-keyboard-matrix-tutorial.html"

Thanks I had heard about ghosting, but had decided not to put diodes in as the way this panel will be used I wouldn't think will use multiple button presses. Thanks for the link though, I will look at it for future projects.