Go Down

Topic: The project is done (Old 49 keys casio) to midi using Arduino MEGA (Read 1 time) previous topic - next topic

Oday_Alasali

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

Code: [Select]

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

Grumpy_Mike

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

Oday_Alasali

Ok, thanks for your efforts,and good night. 

Grumpy_Mike

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.

Oday_Alasali


Grumpy_Mike

There is something odd about this matrix

Code: [Select]
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.

Oday_Alasali

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??

Code: [Select]

#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);
}

Oday_Alasali

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  :smiley-sad:

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.


Grumpy_Mike

Quote
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.

Oday_Alasali

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

Grumpy_Mike

1) remove the chips on your keyboard.
2) test the code again to see if all the keys are working but see 4 below.
3) I would delete the keyToMIDI[] array and change the pressed variable to equal just:-
Code: [Select]
pressed = kpd.key[i].kchar;

4) get the keys array the right size, you have defined only a 6 by 9 array but you have told your program it is a 7 by 10. This means that the code will look outside the bounds of your array to get a number and so it will not return the correct key. When you do this you should get a unique key number for every key you press.

Then you should get notes but they will be in the wrong order.

To get them in the right order you have to change about the numbers in the keys array. See if you can think of a strategy to use.


Oday_Alasali

Well i don't understand why do you mean by the chip is it the thing I marked in the first picture ??? if that is what you mean I can easly unsolder it and remove it.


and if your asking what is soldered below the board on the rear side there are resistors and I attached that too for you to see

Grumpy_Mike

Quote
are resistors and I attached that too for you to see
Those are not resistors they are diodes. I thought these were chips from the back but I can see now they are diodes, keep them in.

The big problem is that you do not know the circuit of that keyboard. You could trace it and that would help to get the circuit right.

Have you ever had all the keys working producing different numbers for each key?

Oday_Alasali

Those are not resistors they are diodes. I thought these were chips from the back but I can see now they are diodes, keep them in.

The big problem is that you do not know the circuit of that keyboard. You could trace it and that would help to get the circuit right.

Have you ever had all the keys working producing different numbers for each key?
Yes with a code you gave me all the keys worked but some are repeated for the same note, so the repetition occurred in all codes I've tried till now even once I didn't even post that I modified alone

Oday_Alasali

After all of this please tell me how to start now I'm really stuck knowing nothing of what to do or how, or is it impossible to run up this keyboard as midi after all this work

Go Up