Introduction: 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.
Step 1: Watch the Video!
Here is an 8 minute video with closed captioning that demonstrates all the steps below from start to finish!
Step 2: 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
- Arduino UNO: http://amzn.to/2dq41Mv
- 74HC595 shift registers: http://amzn.to/2dt6moT
- Resistor pack: http://amzn.to/2d8uQaw
- Perfboard: http://amzn.to/2cQcN7q
- MIDI port: http://amzn.to/2dt5Tmp
- Male pin headers: http://amzn.to/2dqw79G
- Female pin headers: http://amzn.to/2dHhu4Z
Soldering gear:
- Weller WES51 Analog Soldering Station: http://amzn.to/2dq7Q4m
- MG Chemicals Silver Solder: http://amzn.to/2dHj0nq
- Helping hand: http://amzn.to/2dc553O
Prototype gear:
- Multimeter: http://amzn.to/2dc54N6
- Breadboard & Jumpers: http://amzn.to/2dHknm2
Step 3: 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
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
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
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
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?
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
Plug the cable ribbon into place, matching the rows and columns of the scan matrix.
Step 10: 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
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
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
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
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.
79 Comments
Question 3 years ago on Step 1
Hi, why your videos appears to me as private! I could see them long ago. Did you delete them or are they on another video platform? Thanks and nice proyect!
Answer 1 year ago
Looks like there's one here:
https://www.dailymotion.com/video/x62dq9c
Question 1 year ago
only usb not midi cable is posible ?
2 years ago
I want to add transpose buttons, any advice?
Reply 2 years ago
nevermind, I've done it
Question 2 years ago on Introduction
Hi,
Thanks for making this guide. I can't see the video bc it says it's private. It seems like it is working for other people, though. Am I doing something wrong?
Question 4 years ago
I've make it. But i wasn't able to press 2 keys simultaneously like evan did in the video. It work when i press 2 key that not in same octave like C3 and C5, but won't work if i press C3 and D3. Can anyone help me?
Answer 2 years ago
https://www.youtube.com/watch?v=je3EDVs8Fno&feature=youtu.be
Dj DMcMagal.
ddmcmagal@gmail.com
Answer 4 years ago
Hi, i have the same problem, its possible that it is for the code programm.
Question 3 years ago
Has anyone succeeded using the Arduino USB port instead of the MIDI port?
Any insights? a tutorial link maybe? :)
thanks!
Answer 2 years ago
https://www.youtube.com/watch?v=je3EDVs8Fno&feature=youtu.be
Dj DMcMagal.
ddmcmagal@gmail.com
3 years ago on Step 4
54 tuşlu piyano matrix nasıl hesaplanır
Reply 2 years ago
https://www.youtube.com/watch?v=je3EDVs8Fno&feature=youtu.be
Dj DMcMagal .
ddmcmagal@gmail.com
Question 3 years ago
I dont get it. I have the same PSR-150 keyboard and have it hooked up the same way. But its not working. You show that you have a 6x11 and in the video you have the color of the leads inverted. Our boards have diodes so it only flows one way but based on the code you have 11 output and 6 input? but by the way you used your multimeter its the opposite. I took it apart 3 times and still cant get it to work i even tried it in a pullup config to no avail.
EDIT: so it ends up that he does in fact have an 11x6 pull down matrix. Now the only problem i have is that 8 keys are showing up at the same time
3 years ago
what should I do if I have 8 inputs instead of 6?
Can I expand my input with 74HC595 shift register?
My keyboard is very big and has 2, 18 pin connectors labeled as 8 inputs and 10 outputs each
Question 4 years ago on Step 12
I have serious problems. There are informations on a serial port in very fast rate and I can not do anything about that. It happens even if I plug off everything. I sat for about 40 h on it, I am so tired of this nonsense, I don't know what to do. Anybody, help!
Answer 3 years ago
Loose pull up or pull down resistors. the arduino expects either 0 or 5 volts. If the pull up or pull down resistors come loose, the whole thing sends multiple random notes. If you connect it to MIDIOX, you can see the stream of messages, unplug your MIDI cable and then carefully scroll through what you captured in MIDIOX. It helps a lot.
Answer 4 years ago
I've finished the project, but still don't know why that happend, the problem just magically disappeared :p
Tip 3 years ago
For a pull-down config, those having sequencing problem of keys! change the code in the setup() function to below.
for(int rowCtr = 0; rowCtr < NUM_ROWS; rowCtr++)
{
for(int colCtr = 0; colCtr < NUM_COLS; colCtr++)
{
keyPressed[rowCtr][colCtr] = false;
keyToMidiMap[rowCtr][colCtr] = note;
note++;
}
}
Question 4 years ago
I used pull up config for 8x8 matrix but when I press key , 8 notes appear