Hello,
I have an old Casio keyboard, model CTK50, a very simple one, no velocity, aftertouch, just a keyboard matrix being processed by an LSI which outputs some simple sounds. I'm trying to add MIDI in so I can play some midi clips from my PC or a sequencer and make the keyboard play from an external source. Luckily, I found the service manual (CASIO CTK-50 SERVICE MANUAL Pdf Download | ManualsLib) and I have the exact matrix used in this keyboard:
Then with the help of the service manual I found which pins in the ribbon cable are the KCs and the KIs:
So I wired up the arduino according to the schematic, using D2-D10 for the 9 KCs control signals and A0-A5 for the KIs input signals and using a simple 6N139 configuration for the midi connection.
After that, I started to write the code. If I didn't get it wrong, I understood that the KCs are continuosly put to 5V by the LSI one after the other every 2ms (according to the manual), so I have to make the arduino put out 5V when a certain midi note arrives, as if it's a KI signal; that way the LSI recognizes that, for example sending a C2, KC1 is 5V and so KI is going up to 5V while the note on signal is sent, then KI should go to 0V when the note off is sent.
So, the combination of a certain KC and a certain KI make a certain note sound from the keyboard.
I found an old post of a project similar to mine, which says that with the classic functions (digitalWrite, digitalRead) all the scanning and control would be very slow and so the direct port manipulation would be the right way to proceed (Adding MIDI input to pre-MIDI synthesizer with matrix keyboard - Audio - Arduino Forum). So, I started taking the last code in this thread and modifying with my declarations: I can see that midi signals are received as the arduino RX light goes up with note on-note off signals but I have no sound from the keyboard. Another problem I encountered is that if I put the arduino A0-A5 in input mode, all the keys in the keyboard won't work anymore, so I'm thinking if I have to put diodes (RIBBON PIN ---K|----ARDUINO PIN) to prevent any problem related to the input being a current sink.
Sorry for the long post, I wanted to be as detailed as possible.
Any help would be appreciated, thank you! ![]()




