Hello, I posted earlier about another music project but after several days of trying to fix code I wanted to put it on hold for a while. I took apart one of my electronic keyboards which had midi out but I want to make it as diy as possible. So I took the keys out and left the matrix chip and other things away.
Now I have figured out how many columns and rows it has inside the keyboard matrix
But the problem is the library im using seems to only accept one number into the key mapping
Im using Pro Micro cheap china copy
My keyboard has 49 keys
8 rows and
7 columns (7th is just one Note)
it turns into 15 wires
Connected to my Arduino pro micro (you can find pin-in inside code)
Now my problem is I don’t know how to name code the keys for the “char hexaKeys”
since its such a big number on these keys
First I tried to name them with C1, C1# // D2, D#2, and so on
But I realised it didn’t accept more than one letter into the mapping
So I tried to do the alphabet and numbers but its not enough for 49 keys
“char hexaKeys[ROWS][COLS] = {
{‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’},
{‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’},
{‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘Y’},
{‘X’, ‘Z’, ‘1’, ‘2’, ‘3’, ‘4’, ‘5’},
{‘6’, ‘7’, ‘8’, ‘9’, ‘0’, ‘6’, ‘7’},
{‘0’, ‘1’, ‘2’, ‘3’, ‘5’, ‘6’, ‘7’},
{‘0’, ‘1’, ‘2’, ‘3’, ‘5’, ‘6’, ‘7’},
{‘0’, ‘0’, ‘0’, '0, ‘0’, ‘0’, ‘0’},”
Then I started thinking maybe I have to write another code, or can I somehow convert this hex into something else that can fit characters into the code?
I want to turn this later on into midi events (usb or analog)
I started thinking more while writing the topic and I tried to put the notes into the graph in the code comments and its like my brain hit a wall and I realised I am going to deep and “entering the matrix” .
(As you can see in the code with hexakeys its all a mess but thats not the trouble right now)
Maybe im misunderstanding this library?
Music aspect will have to be solved later anyway
. But if I at least could give the matrix keys a name I could later transfer them to notes with the help of serial monitor. Appreciate all help and insight
library: https://github.com/Chris--A/Keypad
example: https://github.com/Chris--A/Keypad/blob/master/examples/CustomKeypad/CustomKeypad.ino
/* @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 = 8; //8 rows
const byte COLS = 7; // 7 columns (each column is 1 / 4 octave of thekeyboard which is 8 notes)
//Math to clarify the music ascept and make sure i think of this the right way
// I am not including the last column with only one single note in this
// so one octave is 12 notes
// and 12 notes are = 1.5 columns (looking at PCB)
// which means 8 notes is one column (12 divided by 1.5)
// since it has 6 columns which are full it must be (8*6=48) 48 notes and that gives me 4 octaves of notes (correct, not counting the last 49th note)
// The columns all each have 8 diodes for each switch, which then if a key i press together
// -and separate from inputs (depending on switch pressed) goes to the output wires
// the input wires (goes to column later goes through the diodes depending on key pressed)
// then the signal coming from diodes goes to the output wires
// output wires later goes into (Arduino (micro pro) IN PINS 16, 14, 15, 18, 19, 20, 21)
//
//
// 7 columns
//
//ROWS >>>>>
//ROWS>>>>>
//ROWS>>>>
///COLUMNSVVVVVVVVVVVVVVVV
////VVVVVVVV
///VVVVVVVVVVVVVVVV
//define the cymbols on the buttons of the keypads (<- comment is from original library example)
char hexaKeys[ROWS][COLS] = {
{'c1', 'g1', 'd1', 'd#1', 'e1', 'e#1', C, ,
{'c#1', 'g#1', 'e2', 'g1', 'c1', 'g1',f},
{'d1', 'a1', 'e#2', 'g1', 'c1', 'g1',f},
{'d#1', 'a#1', 'f2', 'g1', 'c1', 'g1',f},
{'e1', 'b1', 'c2', 'g1', 'c1', 'g1',f},
{'e#1', 'c2', 'c2', 'g1', 'c1', 'g1',f},
{'f1', 'c#2', 'c2', 'g1', 'c1', 'g1',f},
{'f#1', 'd2', 'c2', 'g1', 'c1', 'g1',f},
};
byte rowPins[ROWS] = {2, 3, 4, 5, 6, 7, 8 , 9}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {16, 14, 15, 18, 19, 20, 21}; //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();
if (customKey) {
Serial.println(customKey);
}
}