Hi! I am working on a small 4x4 MIDI keyboard/controller. I am using an Arduino clone, the Teensy. So for I have gotten it to "hold" whatever key I am pressing on the keypad, but not let go. I am using the Keypad library and I am wondering if it is possible to determine if no key is pressed and if it's possible to send one note off command for every note, at once.
Here is my code so far:
/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
#include <Keypad.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'0','1','2','3'},
{'4','5','6','7'},
{'8','9','A','B'},
{'C','D','E','F'}
};
byte rowPins[ROWS] = {0,1,2,3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7,6,5,4}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
}
void loop(){
char customKey = customKeypad.getKey();
int ckey = customKey - '0';
int cKey = ckey - 7;
int finalKey;
int finalNote;
if (customKey) {
if (ckey <= 9) {
finalKey = ckey;
}
if (ckey >9) {
finalKey = cKey;
}
finalNote = finalKey + 60;
usbMIDI.sendNoteOn(finalNote, 64, 1);
}
else {
usbMIDI.sendNoteOff(finalNote, 0, 1);
}
}
I am sure there are many mistakes, but I am hoping you can help me achieve my goal. Thanks in advance.