Hello guys,
its my first post in this forum and i hope i did everything right.
My Problem:
I'm trying to build a 8x8 Matrix with buttons with an Arduino pro micro.
I build and wired everything up, but although I used diodes, I have a problem with ghosting.
I checked every switch and every circuit twice now, everything is wired up properly.
Just to make it clear, I added two diodes to every switch, because theoretically those are two buttons(ON/OFF/ON). I hope this is understandable.
I orientated myself at this post and changed the code a bit: Might have bit off more than I can chew. 56 buttons, 5 rotaries and 2 joys - Project Guidance - Arduino Forum
That's the code I used:
Because windows is dump, i had to simulate two joysticks, but the problem also occurs when I'm just using one, so that shouldn't be a problem(I think?).
#include <Keypad.h>
#include <Joystick.h>
#define ENABLE_PULLUPS
#define NUMBUTTONS0 32
#define NUMBUTTONS 32
#define NUMROWS0 4
#define NUMCOLS0 8
#define NUMROWS1 4
#define NUMCOLS1 8
#define JOYSTICK_COUNT 2
byte buttons0[NUMROWS0][NUMCOLS0] = {
{0, 1, 2, 3, 4, 5, 6, 7},
{8, 9, 10, 11, 12, 13, 14, 15},
{16, 17, 18, 19, 20, 21, 22, 23},
{24, 25, 26, 27, 28, 29, 30, 31}
};
byte buttons1[NUMROWS1][NUMCOLS1] = {
{0, 1, 2, 3, 4, 5, 6, 7},
{8, 9, 10, 11, 12, 13, 14, 15},
{16, 17, 18, 19, 20, 21, 22, 23},
{24, 25, 26, 27, 28, 29, 30, 31}
};
byte rowPins0[NUMROWS0] = {0, 1, 10, 14};
byte colPins0[NUMCOLS0] = {2, 3, 4, 5, 6, 7, 8, 9};
byte rowPins1[NUMROWS1] = {A0, A1, A2, A3};
byte colPins1[NUMCOLS1] = {2, 3, 4, 5, 6, 7, 8, 9};
Keypad buttbx = Keypad( makeKeymap(buttons0), rowPins0, colPins0, NUMROWS0, NUMCOLS0);
Keypad buttbx1 = Keypad( makeKeymap(buttons1), rowPins1, colPins1, NUMROWS1, NUMCOLS1);
Joystick_ Joystick[JOYSTICK_COUNT] = {
Joystick_ (0x08, JOYSTICK_TYPE_JOYSTICK, 32, 0, false, false, false, false, false, false, false, false, false, false, false),
Joystick_ (0x09, JOYSTICK_TYPE_JOYSTICK, 32, 0, false, false, false, false, false, false, false, false, false, false, false)
};
void setup() {
Joystick[0].begin();
Joystick[1].begin();
}
void loop() {
CheckAllButtons0();
CheckAllButtons1();
}
void CheckAllButtons0(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[0].setButton(buttbx.key[i].kchar, 1);
break;
case RELEASED:
case IDLE:
Joystick[0].setButton(buttbx.key[i].kchar, 0);
break;
}
}
}
}
}
void CheckAllButtons1(void) {
if (buttbx1.getKeys())
{
for (int i = 0; i < LIST_MAX; i++)
{
if ( buttbx1.key[i].stateChanged )
{
switch (buttbx1.key[i].kstate) {
case PRESSED:
case HOLD:
Joystick[1].setButton(buttbx1.key[i].kchar, 1);
break;
case RELEASED:
case IDLE:
Joystick[1].setButton(buttbx1.key[i].kchar, 0);
break;
}
}
}
}
}
I hope someone can help me!
Many thanks in advance!


