4x6 Button Matrix keypad.h wrong buttons

Hi fellow Arduino'ers,

i build with my arduino micro an 4x6 Buttonmatrix for a Game.
I can't access the first button (Doesn't match with any Pin setup).
Buttons two to seven are working perfectly. But the the problem appears.
If i press 8 the Controller output is 8 -> 9 -> 10 -> 11 -> 8 -> 9 -> 10 -> 11. If i press any other button it is the same result. The same behavior is for the buttons 14 - 17. The Buttons 12, 13 and 18 are working.

Code is below. Hope anyone can help me. Tried to fix it for many hours and don't catch the error.

#include <Keypad.h>
#include <Joystick.h>

#define NUMBUTTONS 24
#define NUMROWS 4
#define NUMCOLS 6
#define LIST_MAX 24

byte buttons[NUMROWS][NUMCOLS] = {

byte rowPins[NUMROWS] = {11,10,9,8}; 
byte colPins[NUMCOLS] = {7,6,5,4,3,2}; 

Keypad buttbx = Keypad( makeKeymap(buttons), rowPins, colPins, NUMROWS, NUMCOLS); 

  false, false, false, false, false, false,
  false, false, false, false, false);

void setup() {

void loop() { 


void CheckAllButtons(void) {
      if (buttbx.getKeys())
       for (int i=0; i<LIST_MAX; i++)   
              if ( buttbx.key[i].stateChanged )   
                switch (buttbx.key[i].kstate) {  
                    case PRESSED:
                    case HOLD:
                              Joystick.setButton(buttbx.key[i].kchar, 1);
                              Joystick.setButton(buttbx.key[i].kchar, 0);
                    case RELEASED:
                    case IDLE:
                              Joystick.setButton(buttbx.key[i].kchar, 0);

Don't use pins 0, 1 or 13 with the button matrix

0 and 1 are used by the Serial interface and 13 is used by the built in LED of many Arduinos and can cause problems

Which Arduino are you using ?

Good advice, but . . ?

I use this arduino: Arduino Micro — Arduino Official Store

Note if i remove the cable between Button 3 and 9. The Button 9 is working without the output cycle (8->9->10->11->8->9->10->11).

Seems like the On-On Toogle Switch is the Problem.
Is there any Solution just with a few code edits?
Don't want to buy new toogle switches or soldering the cable new.

If a switch is going to hold in the "on" position, or you expect to press more than two buttons at any one time, you need a diode in series with each button/ switch on the matrix.

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