Introduction: Add MIDI Port to Keyboard

Picture of Add MIDI Port to Keyboard

Having a MIDI keyboard will let you control digital audio workstations (DAWs) like Pro tools, FL Studio, Ableton Live, etc. As well, it will connect to a wide variety of MIDI gear such as table top synths.

This tutorial is useful for those who already have a non-MIDI keyboard, and want to upgrade it for music production use.

www.evankale.blogspot.ca

Step 1: Watch the Video!

Here is an 8 minute video with closed captioning that demonstrates all the steps below from start to finish!

Click here to watch on YouTube

Step 2: What You'll Need

Picture of What You'll Need
  • 1 Arduino UNO, or any Arduino alternative
  • 2 Serial to parallel shift registers
  • Resistors (1 220Ω for the MIDI port, and 6 10kΩ for pull-up resistors - this will depend on step 4)
  • 1 Proto board
  • 1 Female MIDI port
  • 1 Male pin header

And the tools we'll need are breadboards, breadboard jumpers, a multimeter, soldering equipment and wires.

Where to buy

Soldering gear:

Prototype gear:

Step 3: Open the Keyboard

Picture of Open the Keyboard

Open up the keyboard, and snip off the ribbon cable from the main board that goes to the keys.

Step 4: Figure Out the Scan Matrix

Picture of Figure Out the Scan Matrix

Put the multimeter on continuity (or resistance) reading. Attach the probes to two pins at a time and sweep the keyboard to find our keys.

For my keyboard, I have a 17 pin ribbon, which I concluded to be a 6x11 scan matrix. To fit all the keys on the Arduino UNO, I'll be combining 11 pins into 3 using 2 shift registers. Then our total input pins is then reduced from 17 to 9.

(The result of this will be different for every keyboard but the procedure will be the same)

Step 5: Setting Up First Shift Register

Picture of Setting Up First Shift Register

We'll start with the first shift register.

Wire up the ground and voltage pins as seen in the picture.

Then plug in our Clock, Latch, and Data lines and plug it into the digital pins 8,9,10 of the Arduino. Then we wire up the voltage and ground from the arduino to the board.

Run the first bit of test code from the image. Taking our voltmeter to measure the output of each of the data pins, we should 0 voltage for pins that we are shifting out a 0 and positive voltage for the pins we are shifting out a 1.

Step 6: Daisy Chain Second Shift Register

Picture of Daisy Chain Second Shift Register

Once we have our first shift register working, we're going to daisy chain our second one.

We'll wire up the voltage and gnd just like the first one, then hook up the additional data pin of the first chip to the Data pin of the second chip. Then we'll also need to hook up Latch and Clock pins of the two chips (see image).

Now we plug in our Clock, Latch, and Data lines again same way as we did before, and make a small change in our Arduino program to accomodate for the second shift register (see image).

We should see the same alternating pattern with our data pins from this program throughout all of our data pins.

If you're wondering which chip comes first, then simply shift out 8-bits of 0's and 8 bits of 1's at a time and check which chip is outputting the signal.

Step 7: Setting Up Resistors

Picture of Setting Up Resistors

Hook up the power to our second breadboard.

We're going to extend the first 11 of our data pins from the shift registers to the second board (see image).

Then we're going to bring 6 lines into 6 digital pins of the arduino.

We'll need to add a 10k ohm resistor to ground for each of these lines so that we have a pull-down resistor configuration. This will guarantee that we have the signal we want when the switches on the keyboard are open.

Step 8: Pull Up or Pull Down?

Picture of Pull Up or Pull Down?

One thing to note, if this direction of current doesn't work for your keyboard, we can switch over to a pull-up resistor configuration by simply doing the following (see the image):

  • First we remove the voltage and ground connection to the shift registers.
  • Then we connect our 6 resistors to positive voltage instead of ground.
  • And we also want to keep the shift register pins connected just the way they are.
  • This will create the pull-up configuration you see in the diagram.

Step 9: Add the Keyboard Ribbon

Picture of Add the Keyboard Ribbon

Plug the cable ribbon into place, matching the rows and columns of the scan matrix.

Step 10: Setting Up MIDI Port

Picture of Setting Up MIDI Port

We're going to wire the serial output pin of the port to the serial output of the Arduino, which is pin 1 for the Arduino UNO.

Then we wire up the ground pin and voltage pins like the diagram.

Step 11: Upload Arduino Program

Download the full Arduino code from GitHub (choose the correct version; pull-up or pull-down).

Watch the video from Step 1 at 4:30 - 5:45 to review any necessary changes you need to make to the code in order to get it to work with your specific configuration.

Step 12: Testing

Picture of Testing

To test our keyboard, we'll plug in our MIDI port to the computer and fire up a MIDI monitor program like MIDI-OX.

We'll hit all the keys to make sure we have everything wired up correctly.

If you don't have a MIDI port, you can get get one of these MIDI to USB adapters (see image) for a few bucks.

Step 13: Transferring to Proto Board

Picture of Transferring to Proto Board

Once everything is working, we're going to transfer everything from our breadboard to the proto board and solder in all the connections.

Plug our wires into the Arduino just the way we had it before, and use the male pin headers here to lock them in place.

Step 14: Putting the Keyboard Back Together

Picture of Putting the Keyboard Back Together

I then traced over the shape of the MIDI and USB ports onto the keyboard case and cut out the hole.

I added a few popsicle sticks to support the Arduino and proto board and hot glued them in place.

Step 15: Final Testing

Picture of Final Testing

Plug it in, fire up a DAW, and give it a try!

That's it!

If you liked this instructable, then perhaps you'll like some of my other projects!

You can check them out at Blogspot, or visit my YouTube Channel.

Comments

Duf999 (author)2017-11-15

Does the keyboard still need to be powered (either by batteries or external cable) or is the arduino powering it?

Examper (author)2017-11-13

What gauge wire is suggested?

zikuuart (author)2017-10-08

Can i make it without the shift registers?
i have a 8x4 keyboard matrix so i have enough pins on aduino.
what have i do with the arduino software?
i just erase the sift register part

speedtouchd made it! (author)2017-08-19

I used Hairless MIDI and loopMIDI to covert serial to MIDI (use only 1usb link) and it works.

shinchan2788 (author)2017-07-29

can we use a usb b type port instead of regular midi port for the project ... ???

Nairod785 (author)2014-12-02

Good job !
But now can you play the piano without the MIDI connected?

kc0nlh (author)Nairod7852016-04-27

not if you follow this tutorial. would be nice to see one where they dont destroy the local playback functionalty

LuaM3 (author)kc0nlh2016-06-27

Well, it's not destroy, but superseded. You could have a switch and two ribbon cables and call it a day.

TheNH (author)LuaM32017-07-18

Easier way is to just re-use the built in matrix. When the keyboard is on the Arduino can tap and listen to the signals on both sides of the matrix. Just mute the keyboard when using it this way. If you use USB Midi as the output, then you'l have enough pins for all the keys without shift registers.

TheNH (author)TheNH2017-07-18

Well, you'l have enough pins if they keyboard has less then 50 keys.

F.ZAMPIVA (author)2015-08-25

hi, I'm trying to do this with a Casio keyboard CTK480.

But I'm not getting, help me?

I have a pull-up 8x8 matrix.

I used only one 74HC595.

I changed the codes ...

But when I press a button detects the Synthesia 8 keys. I do not know how to solve.

AcirG1 (author)F.ZAMPIVA2017-02-02

I'm having the same issue :/

łgruca made it! (author)2017-01-21

Thanks a lot! My Old Yamaha PSR-18 got a new life.

Hardest part was to map cables to keybord sections.

Another thing was when I was trying to connect both at the same time, midi out and internal electronics, but it's just not working.

jnftech (author)2016-09-15

Is anyone aware of a projects to do the reverse of this? In other words, adding a MIDI input to old keyboards (like an old Casiotone) so you can trigger the keyboard's own sounds from another MIDI source?

polikarpa (author)2016-08-21

Good Project!

I tried to make it in a toy piano but it has some resistors to difference the keys. I don't understand how it works. Do you have some idea?

I add an image with the circuit

Tank You very much!

tucstone (author)2016-03-25

i have a question. Im trying to make a footswitch for controlling abletons record stop and start. im trying to make a usb 1 button switch. i was wondering if you could give me any advice or direct me in the right path. thank you for all your help. ive already used ur video to make a midi drumset out of my xbox 360 rock band set. any help would be greatly appriciated. thanks again

LuaM3 (author)tucstone2016-06-27

Easier way I could think of:
Get a leonardo or sparkfun pro micro (or any clone therein) and take a look at the keyboard examples in arduino.cc

pupiloho (author)2016-06-14

Can this be made with an arduino nano?

LuaM3 (author)pupiloho2016-06-27

Actually yes, but if you're going small, I'd suggest you use something like a teensy or a Sparkfun Pro Micro.

LuaM3 (author)LuaM32016-06-27

That's since, with some code changes, it could be used for USBMIDI and regular MIDI at the same time.

look_at_all_the_buttons (author)2016-03-07

Great stuff! However, all I can find online in midi out! Is there a way to create a midi in port? Could it be done with the same arduino?!

I have been wondering the same thing as I have a cheap roll up piano that sounds good but is a pain in the butt to play due to the so so construction methods. I have successfully removed the rubber from hell and exposed the scan matrix but im unsure as to where to go from here.

Brayor (author)2016-03-24

Could someone make a circuit diagram plz?

Sean7805 (author)2016-03-16

Can I skip the MIDI part and make the arduino act like a usb to midi converter so I can just plug it in directly to my computer?

JASHJ (author)2015-10-27

I wanna make that ! But its damn technical !!!!! Sm1 plz help me!!!!!

-Matúš- (author)2015-03-10

Hi, are the shift registers used also because of the speed of scanning or only because of the saving IO ports? I am asking because I am trying to do the similar project. Now I have connected my matrix keyboard directly to arduino mega. It is working, but there is time delay between pressing the key and playing the sound from the PC. Thanks

RowanCant (author)2015-02-05

you could soldier cables back to the original and have midi in and the original functionality of the old keyboard if you wanted to.. Or you could make an amplifier and use the speakers in the keyboard as fold backs for the player.

Also, worth noting that this keyboard is on/off so there are no multitouch features, it's not going to play loud or quiet when you play hard or gentle.

Awesome instructable though.

Tachyon (author)2014-12-10

This is a great idea and for cheap keyboards it makes sense as is. However I'm betting a lot of people would like a way to switch back to the original keyboard functions when not using the midi.
probably the easiest would be a switch connected to an Arduino pin that tells it to pass the keyboard matrix output back to the original input. possibly using similar bit expanders.

freilly1 (author)2014-12-10

Arduino UNO for $7? Where?

Tachyon (author)freilly12014-12-10

everywhere. e-bay, aliexpress, etc.

script_coded (author)2014-12-07

Wahw!
Great video!

iam_maker_leo (author)2014-12-02

wow great...

Now I start to learn Cubase for composite something..

And I need a master keyboard.... I think it can be used for me...

About This Instructable

36,324views

271favorites

License:

Bio: www.youtube.com/EvanKale91 === www.facebook.com/EvanKale91 === www.twitter.com/EvanKale91 === www.evankale.blogspot.ca
More by EvanKale:Pokemon Card DoorGuitar Cajon Mod (Internal Snare)Ratchet Knob (Unidirectional mechanism)
Add instructable to: