So I have a 11 x 8 diode button keypad.
here is my code
const int MIDI_CHAN = 1;
const byte ROWS = 8; //four rows
const byte COLS = 11; //three columns
const int NUM_OF_BUTTONS = ROWS * COLS;
byte keys[ROWS][COLS] = {
{0, 8,16,24,32,40,48,56,64,72,80},
{1, 9,17,25,33,41,49,57,65,73,81},
{2,10,18,26,34,42,50,58,66,74,82},
{3,11,19,27,35,43,51,59,67,75,83},
{4,12,20,28,36,44,52,60,68,76,84},
{5,13,21,29,37,45,53,61,69,77,85},
{6,14,22,30,38,46,54,62,70,78,86},
{7,15,23,31,39,47,55,63,71,79,87},
};
byte rowPins[ROWS] = {7, 6, 5, 4, 3, 2, 1, 0};
byte colPins[COLS] = {9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29};//
byte MIDI_NOTE_NUMS[89] = {0, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108};
void setup() {
Serial.begin(115200);
for(int coln=0; coln<sizeof(colPins); coln++) {
pinMode(colPins[coln], OUTPUT); // Set the mode to OUTPUT
}
for(int rowNa=0; rowNa<sizeof(rowPins); rowNa++) {
pinMode(rowPins[rowNa], INPUT_PULLUP); // Set the mode to INPUT
}
}
void loop() {
for (byte coln = 0; coln<sizeof(colPins); coln++) {
digitalWrite(colPins[coln], LOW);
for (byte rown = 0 ; rown < sizeof (rowPins) ; rown++)
{
boolean state = digitalRead(rowPins [rown]);
if(state == LOW){
usbMIDI.sendNoteOn (MIDI_NOTE_NUMS[keys[rown][coln]], 110, MIDI_CHAN);
Serial.print(" rown ");
Serial.print(rown);
Serial.print(" coln ");
Serial.print(coln);
Serial.print(" caracter = ");
Serial.print(keys[rown][coln]);
Serial.print(" SE ACTIVO ");
Serial.println(state);
}
delay(5);
}
digitalWrite (colPins[coln], HIGH) ;
}
}
and here is my issue:
{ row: 0,
col: 0,
note: 0,
unwantedNote: { row: 0, col: 1, note: 8 } }
{ row: 0,
col: 1,
note: 8,
unwantedNote: { row: 0, col: 2, note: 16 } }
{ row: 0,
col: 2,
note: 16,
unwantedNote: { row: 0, col: 3, note: 24 } }
{ row: 0,
col: 3,
note: 24,
unwantedNote: { row: 0, col: 4, note: 32 } }
{ row: 0,
col: 4,
note: 32,
unwantedNote: { row: 0, col: 5, note: 40 } }
{ row: 0,
col: 5,
note: 40,
unwantedNote: { row: 0, col: 6, note: 48 } }
{ row: 0,
col: 6,
note: 48,
unwantedNote: { row: 0, col: 7, note: 56 } }
{ row: 0,
col: 7,
note: 56,
unwantedNote: { row: 0, col: 8, note: 64 } }
{ row: 0,
col: 8,
note: 64,
unwantedNote: { row: 0, col: 9, note: 72 } }
{ row: 0,
col: 9,
note: 72,
unwantedNote: { row: 0, col: 10, note: 80 } }
{ row: 0,
col: 10,
note: 80,
unwantedNote: { row: 0, col: 0, note: 0 } }
whenever I press a key on the row 0 there are not one but two key presses detected.
one for row 0 col x and another one for row 0 col x + 8.
there are no shorts, I verified with a tester. any idea what might be the cause?