The project is done (Old 49 keys casio) to midi using Arduino MEGA

In order of keys I suppose it has to be like this and I hope this is what you are asking for, or then I'ma be so stupid :sob:

KEY    MIDI NOTES
READS    36-84
+
KEY 
NUMBERS
______  ___________
Key 36(1)  36: C	
Key 45(2)  37: C#/Db	
Key 54(3)  38: D	
Key 63(4) 39: D#/Eb	
Key 72(5)  40: E	
Key 81(6)  41: F	
Key 37(7)  42: F#/Gb	
Key 46(8)  43: G	
Key 55(9)  44: G#/Ab	
Key 64(10)  45: A	
Key 73(11)  46: A#/Bb	
Key 82(12)  47: B
Key 38(13)  48: C	
Key 47(14)  49: C#/Db	
Key 56(15)  50: D	
Key 65(16)  51: D#/Eb	
Key 74(17)  52: E	
Key 83(18)  53: F	
Key 39(19)  54: F#/Gb	
Key 48(20)  55: G	
Key 57(21)  56: G#/Ab	
Key 66(22)  57: A	
Key 75(23)  58: A#/Bb	
Key 84(24)  59: B	
Key 40(25)  60: C	
Key 49(26)  61: C#/Db	
Key 58(27)  62: D	
Key 67(28)  63: D#/Eb	
Key 76(29)  64: E	
Key 85(30)  65: F	
Key 41(31)  66: F#/Gb	
Key 50(32)  67: G	
Key 59(33)  68: G#/Ab	
Key 68(34)  69: A	
Key 77(35)  70: A#/Bb	
Key 86(36)  71: B	
Key 42(37)  72: C	
Key 51(38)  73: C#/Db	
Key 60(39)  74: D	
Key 69(40)  75: D#/Eb	
Key 78(41)  76: E	
Key 87(42)  77: F	
Key 43(43)  78: F#/Gb	
Key 52(44)  79: G	
Key 61(45)  80: G#/Ab	
Key 70(46)  81: A	
Key 79(47)  82: A#/Bb	
Key 88(48)  83: B	
Key 44(49)  84: C

Thanks that looks a lot better.
What are the numbers in brackets? Are they the key numbers? If so then try this code:-

#include <Keypad.h>

const byte ROWS = 7; //Seven rows
const byte COLS = 10; //Ten columns
char keys[7][10] = {
 {1, 2, 3, 15, 14, 13, 12, 11, 10},
 {4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
 {5, 5, 5, 5, 5, 5, 5, 5, 5, 0},
 {6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
 {7, 7, 7, 7, 7, 7, 7, 7, 7, 0},
 {8, 8, 8, 8, 8, 8, 8, 8, 8, 0},
 {9, 9, 9, 9, 9, 9, 9, 9, 9, 0},
};
byte rowPins[ROWS] = {26, 28, 30, 32, 34, 36, 38 ,}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8,}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(49), rowPins, colPins, ROWS, COLS );
byte keyToMIDI[] = { 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};
byte pressed = 32;
byte chanel = 0; // MIDI channel to use

void setup() {
 Serial.begin(115200); // set this the same as Hairless
}

void loop() {
 // Fills kpd.key[49] array with up-to 10 active keys.
 // Returns true if there are ANY active keys.
 if (kpd.getKeys())
 {
   for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
   {
     if ( kpd.key[i].stateChanged )   // Only find keys that have changed state.
     {
       pressed = keyToMIDI[kpd.key[i].kchar];
       switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
         case PRESSED:
           sendMIDI(chanel | 0x90, pressed, 100);
           break;
          case RELEASED:
           sendMIDI(chanel | 0x80, pressed, 0);
           break;
       }
     }
   }
 }
}  // End loop

void sendMIDI(byte type, byte note, byte velocity){
  Serial.write(type);
  Serial.write(note);
  Serial.write(velocity);
}

It compiles but I have not tested it. Set the baud rate of Hairless to 115200.

The array that converts your key presses into MIDI note numbers is called keyToMIDI.

The numbers are the wire number according to the ribbons in the picture I provided and the matrix I will try that code as soon as possible and I will reply back, thanks alot for your help.

The numbers are the wire number according to the ribbons in the picture

Ah, you might have to have a different matrix then, you might get some sounds out of some keys though. It is just a matter of getting them in the right order. I think we are close now though.

Mate I tried this code and for the first time I'm getting the keyboard working also worked for FL studio but as u said its so messed up :grin: most of the keys are working to be Note 36 which is the first note and some keys do different notes for each time you press at it,, But I know that we are nearly close to complete up this thing with your help and I appreciate that.

EDIT: and 2 keys are not reading in midi but they are working and the arduino blinks when pressed

Grumpy_Mike:
Ah, you might have to have a different matrix then, you might get some sounds out of some keys though. It is just a matter of getting them in the right order. I think we are close now though.

Well my diode test to the matrix is 100% right because I think it only work in one way but could the numberings be wrong?? if yes then I'm in a middle of a tornado thats made of possibilities even through coding or pins on the arduino

Sorry but since my head is really missed up I forgot to edit the picture of the pins, It was all changed since the first post but the placements are the same as the code

byte rowPins[ROWS] = {26, 28, 30, 32, 34, 36, 38 ,}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8,}; //connect to the column pinouts of the kpd

OK try this:-

#include <Keypad.h>

const byte ROWS = 7; //Seven rows
const byte COLS = 10; //Ten columns
char keys[7][10] = {
 {1, 2, 3, 15, 14, 13, 12, 11, 10},
 {4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
 {5, 5, 5, 5, 5, 5, 5, 5, 5, 0},
 {6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
 {7, 7, 7, 7, 7, 7, 7, 7, 7, 0},
 {8, 8, 8, 8, 8, 8, 8, 8, 8, 0},
 {9, 9, 9, 9, 9, 9, 9, 9, 9, 0},
};
byte rowPins[ROWS] = {26, 28, 30, 32, 34, 36, 38}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(49), rowPins, colPins, ROWS, COLS );
byte keyToMIDI[] = { 36,42,48,54,60,66,72,78,84,37,43,49,55,61,67,73,79,38,
                     44,50,56,62,68,74,80,39,45,51,57,63,69,75,81,40,46,52,
                     58,64,70,76,82,41,47,53,59,65,71,77,83};
byte pressed = 32;
byte chanel = 0; // MIDI channel to use

void setup() {
 Serial.begin(115200); // set this the same as Hairless
}


void loop() {
 // Fills kpd.key[49] array with up-to 10 active keys.
 // Returns true if there are ANY active keys.
 if (kpd.getKeys())
 {
   for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
   {
     if ( kpd.key[i].stateChanged )   // Only find keys that have changed state.
     {
       pressed = keyToMIDI[kpd.key[i].kchar - 36];
       switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
         case PRESSED:
           sendMIDI(chanel | 0x90, pressed, 100);
           break;
          case RELEASED:
           sendMIDI(chanel | 0x80, pressed, 0);
           break;
       }
     }
   }
 }
}  // End loop

void sendMIDI(byte type, byte note, byte velocity){
  Serial.write(type);
  Serial.write(note & 0x7F);
  Serial.write(velocity);
}

Its still messed up most of the keyboard is reading as the first note

but *All keys are working : before a few didnt even read

OK we are going to have to do some debugging here.
Open the serial monitor and set the baud rate to 115200 from the drop down menu in the corner. Run this code and press the keys on the keyboard in turn and post the printout so I can see if I can work out what is happening.

#include <Keypad.h>

const byte ROWS = 7; //Seven rows
const byte COLS = 10; //Ten columns
char keys[7][10] = {
 {1, 2, 3, 15, 14, 13, 12, 11, 10},
 {4, 4, 4, 4, 4, 4, 4, 4, 4, 4},
 {5, 5, 5, 5, 5, 5, 5, 5, 5, 0},
 {6, 6, 6, 6, 6, 6, 6, 6, 6, 0},
 {7, 7, 7, 7, 7, 7, 7, 7, 7, 0},
 {8, 8, 8, 8, 8, 8, 8, 8, 8, 0},
 {9, 9, 9, 9, 9, 9, 9, 9, 9, 0},
};
byte rowPins[ROWS] = {26, 28, 30, 32, 34, 36, 38}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(49), rowPins, colPins, ROWS, COLS );
byte keyToMIDI[] = { 36,42,48,54,60,66,72,78,84,37,43,49,55,61,67,73,79,38,
                     44,50,56,62,68,74,80,39,45,51,57,63,69,75,81,40,46,52,
                     58,64,70,76,82,41,47,53,59,65,71,77,83};
byte pressed = 32;
byte chanel = 0; // MIDI channel to use

void setup() {
 Serial.begin(115200); // set this the same as Hairless
}


void loop() {
 // Fills kpd.key[49] array with up-to 10 active keys.
 // Returns true if there are ANY active keys.
 if (kpd.getKeys())
 {
   for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
   {
     if ( kpd.key[i].stateChanged )   // Only find keys that have changed state.
     {
       pressed = keyToMIDI[kpd.key[i].kchar - 36];
       Serial.print("Key to look up is:-");
       Serial.println(kpd.key[i].kchar - 36);
       switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
         case PRESSED:
           sendMIDI(chanel | 0x90, pressed, 100);
           break;
          case RELEASED:
           sendMIDI(chanel | 0x80, pressed, 0);
           break;
       }
     }
   }
 }
}  // End loop

void sendMIDI(byte type, byte note, byte velocity){
  /*
  Serial.write(type);
  Serial.write(note & 0x7F);
  Serial.write(velocity);
  */
}

Each three reads are for one key thats what I got ((SOME KEYS GIVES 3 different reads if you keep pressing it))) and i dont know why but I didnt put it here i did 1 press for key in this test

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--33
Key to look up is:--33
Key to look up is:--33

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--34
Key to look up is:--34
Key to look up is:--34

Key to look up is:--34
Key to look up is:--34
Key to look up is:--34

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--40
Key to look up is:--40
Key to look up is:--40

Key to look up is:--20
Key to look up is:--20
Key to look up is:--20

Key to look up is:--2
Key to look up is:--2
Key to look up is:--2

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--4
Key to look up is:--4
Key to look up is:--4

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:-58
Key to look up is:-58
Key to look up is:-58

Key to look up is:--30
Key to look up is:--30
Key to look up is:--30

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--77
Key to look up is:--77
Key to look up is:--77

Key to look up is:--2
Key to look up is:--2
Key to look up is:--2

Key to look up is:--21
Key to look up is:--21
Key to look up is:--21

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--3
Key to look up is:--3
Key to look up is:--3

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--29
Key to look up is:--29
Key to look up is:--29

Key to look up is:--156
Key to look up is:--156
Key to look up is:--156

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36
Key to look up is:--162
Key to look up is:--162
Key to look up is:--162
Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--21
Key to look up is:--21
Key to look up is:--21

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--3
Key to look up is:--3
Key to look up is:--3

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--36
Key to look up is:--36
Key to look up is:--36

Key to look up is:--21
Key to look up is:--21
Key to look up is:--21

Thanks. I will think about this but have to go to bed now as it is 4:44 here. Post later.

Ok, thanks for your efforts,and good night.

Just to check can we go back to reply #17 and check that you still get the same results from the code in that post. I think something might have changes.

Ok will modify that code to midi any try in an hour or so.

There is something odd about this matrix

char keys[7][10] = {
  {1, 2, 3, 15, 14, 13, 12, 11, 10}, // 9 elements in this array
  {4, 4, 4, 4, 4, 4, 4, 4, 4, 4},   // 10 elements in this array but all map to the same number
  {5, 5, 5, 5, 5, 5, 5, 5, 5, 0},   // 10 elements in this array but all map to the same number except the last one
  {6, 6, 6, 6, 6, 6, 6, 6, 6, 0},   // 10 elements in this array but all map to the same number except the last one
  {7, 7, 7, 7, 7, 7, 7, 7, 7, 0},   // 10 elements in this array but all map to the same number except the last one
  {8, 8, 8, 8, 8, 8, 8, 8, 8, 0},   // 10 elements in this array but all map to the same number except the last one
  {9, 9, 9, 9, 9, 9, 9, 9, 9, 0},   // 10 elements in this array but all map to the same number except the last one
};

So there should be the same number of elements in each row. Each number should be different to get a different number for each key.

I suggest the numbers in this array should be the MIDI numbers you want to send.

I tried this code as you said (took from reply 17 and modified it) still messed up and got back the 2 keys not working**************What are you suggesting for me to do, or is it a blocked wall for here??

#include <Keypad.h>

const byte ROWS = 7; //Seven rows
const byte COLS = 10; //Ten columns
char keys[COLS][ROWS] = {
  {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}
};
byte rowPins[ROWS] = {26, 28, 30, 32, 34, 36, 38 ,}; //connect to the row pinouts of the kpd
byte colPins[COLS] = {A0, A1, A2, A3, A4, A5, A6, A7, A8,}; //connect to the column pinouts of the kpd

Keypad kpd = Keypad( makeKeymap(49), rowPins, colPins, ROWS, COLS );
byte keyToMIDI[] = { 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};
byte pressed = 32;
byte chanel = 0; // MIDI channel to use

void setup() {
 Serial.begin(115200); // set this the same as Hairless
}

void loop() {
 // Fills kpd.key[49] array with up-to 10 active keys.
 // Returns true if there are ANY active keys.
 if (kpd.getKeys())
 {
   for (int i = 0; i < LIST_MAX; i++) // Scan the whole key list.
   {
     if ( kpd.key[i].stateChanged )   // Only find keys that have changed state.
     {
       pressed = keyToMIDI[kpd.key[i].kchar];
       switch (kpd.key[i].kstate) {  // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
         case PRESSED:
           sendMIDI(chanel | 0x90, pressed, 100);
           break;
          case RELEASED:
           sendMIDI(chanel | 0x80, pressed, 0);
           break;
       }
     }
   }
 }
}  // End loop

void sendMIDI(byte type, byte note, byte velocity){
  Serial.write(type);
  Serial.write(note);
  Serial.write(velocity);
}

Mate since I started to get hopless I think that these pictures might solve something if you take a look

pictures from key 1 to 49 ((Little board - Long board - Little board)).

In the long board these are the wires I'm numbering from 1-15

I hope that this will make any progress :slightly_frowning_face:

and as you can see my wirings were done on the outer wires to keep a safe line in case something happened and this didnt work in anyway.

still messed up and got back the 2 keys not working**************What are you suggesting for me to do

But did you get the same keys as you did before?

The pictures show some chips soldered on your board. Are you powering them or is it just unpowered?
If they are powered then they will try and scan the matrix themselves. If they are unpowered then they will interfere with the way the Arduino is trying to drive the matrix. Also you should post your pictures as attachments like they describe in the How to use this forum thread.

I would either unsolder those chips or if your soldering skills are not up to it then simply clip off the pins with side cutters and remove the chip. Then you can use your soldering iron and some tweezers to pull out the pins one at a time.
Once you have removed the chips try again with that code and see if all keys start working. When they do we can start to straighten them out.

Grumpy_Mike:
But did you get the same keys as you did before?

The pictures show some chips soldered on your board. Are you powering them or is it just unpowered?
If they are powered then they will try and scan the matrix themselves. If they are unpowered then they will interfere with the way the Arduino is trying to drive the matrix. Also you should post your pictures as attachments like they describe in the How to use this forum thread.

I would either unsolder those chips or if your soldering skills are not up to it then simply clip off the pins with side cutters and remove the chip. Then you can use your soldering iron and some tweezers to pull out the pins one at a time.
Once you have removed the chips try again with that code and see if all keys start working. When they do we can start to straighten them out.

So now what are you advising me to do to get the things right