Just as an exercise I reduced your code to simply this:-
// Push Button to MIDI by Grumpy Mike - May 2018
// Push button wired between input and ground
#include <Bounce2.h>
const int channel = 1;
const byte pinNumbers[] = {16,20,0,4,15,19,1,5,14,18,2,6,13,17,3,7,24,11,12,23,10,9};
Bounce pushButton[22];
byte velocity = 99;
void setup() {
for(int i = 0; i<22; i++){
pushButton[i] = Bounce(pinNumbers[i], 5);
pinMode(pinNumbers[i], INPUT_PULLUP);
}
}
void loop() {
for(int i = 0; i<22; i++){
pushButton[i].update();
if (pushButton[i].fallingEdge()) {
usbMIDI.sendNoteOn(61+i, velocity, channel); // or change 61 to 81 for original note
}
if (pushButton[i].risingEdge()) {
usbMIDI.sendNoteOff(61+i, 0, channel); // or change 61 to 81 for original note
}
}
}
However, your code puzzled me. If you want a 4 by 4 matrix arrangement why have you defined 22 push button inputs?
Also the comment by the note values you send say things like "// 61 = C#4" when you actually are sending note number 81. Why is this?