Introduction: Arduino MIDI-in Shield

This instructable shows how to build a shield to connect devices that send MIDI signals (e.g. a masterkeyboard) to an Arduino.
The basic schematic is derived from: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/

Step 1: The Schematic

Basically the schematic is just an optocoupler with some resistors to decouple the MIDI device from the Arduino.
Note that the DIN connector on the left side is seen from the back (solder pin-side).

Step 2: Board Layout, Parts List, Etc.

Part list:

Resistors (1 piece each): 220 Ohms, 100 kOhms, 3.3 kOhms
Diode: 1N4148
Optocoupler: 4N28
5 PIN DIN connector (MIDI connector)
2 pinheads 1x8
1 pinhead 1x4
1 pinhead 1x6

It will also work with other Optocouplers (e.g. a 4N35, I used a 4N29)

Attached are the necessary files for etching the board and the eagle-files if you want to make modifications.

Step 3: Production

Just a few hints for making the shield:

A very good how-to (that actually worked form me unlike many others) for etching the board can be found here: http://hackaday.com/2008/07/28/how-to-etch-a-single-sided-pcb/

If you are a noob like me and want to modify the board in eagle then try these instructables:
https://www.instructables.com/id/Draw-Electronic-Schematics-with-CadSoft-EAGLE
https://www.instructables.com/id/Turn-your-EAGLE-schematic-into-a-PCB
https://www.instructables.com/id/Make-hobbyist-PCBs-with-professional-CAD-tools-by-

Soldering the pinheads upwards down on the board so you can directly put it on the arduino is a real pain in the ass. I rasped a head of my soldering iron so that it became small enough to do that job. let me know if you have a better solution.

For this board I used a DIN connector that can be soldered directly to it. If you want to use another one be sure to connect the pins with the numbers on the board to the according pins on the connector. In the pic here the pins are seen from the back (where you solder).

Step 4: Programming

The first thing I did was to erase the microcontroller on my Arduino by uploading a sketch without disconnecting the board before. SO BE CAREFUL NOT TO DO THAT!
Newer versions of the Arduino should be smart enough to avoid this by themselves, but it's not that much work to disconnect the shield before uploading....

To test your board I would recommend to use the sketch from here: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/

Comments

author
sspence made it!(author)2012-10-22

According to the spec sheet for the 4N28 chip, the diagram above is wrong. Starting from the top on the right hand side, you should have pin 6 as N/C, pin5 as out to Arduino (with a 270 ohm to +5v), and pin 4 on the bottom as ground. A better chip would be the 6n138, and follow this schematic.

author
carkat made it!(author)2012-10-22

hi,
sorry, but i don't see the difference. the schematic is exactly as you explained. the only difference is that i use a 3k3 instead of 270R to +5V, which should not make a difference in means of working/not working.

author
sspence made it!(author)2012-10-22

You are grounding the base of the photo transistor through a 100k resistor. why?

author
carkat made it!(author)2012-10-22

as sid in the instructable in step 1 this is not my schematic, i got it from somewhere else. but from my (limited) understading of electronics this should not make any difference if there are 100k or no resistor.

author
sspence made it!(author)2012-10-22

Apparently, from the comments of others, it does make a difference. They could not get your schematic to work unless that connection was clipped. I can't see a reason for it in the first place, according the the datasheet for the part.

author
brandondrury made it!(author)2012-09-08

Thanks for the schematic! I have a bit of trouble, too, until I ditched the 100k resistor. It's working like a charm.

author
nevvkid made it!(author)2012-06-07

Is there anybody who got this schematic working? In the Arduino Forum ( http://arduino.cc/forum/index.php/topic,22447.0.html ) somebody was telling that the midi connector is reversed is this true? The Sparkfun MidiShield has it reversed http://www.sparkfun.com/datasheets/DevTools/Arduino/MIDI_Shield-v13.pdf
But they are using a different optocopler.
Here some other guy is telling that the schematic is wrong - http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/60#71

In the end i want to use it with the Arduino MIDI Lib http://arduino.cc/playground/Main/MIDILibrary it would be helpful to have Schematic with an LED or Servo to check if it's working and the related sketch for it.

Anybody out there who could help?

Thanks!

Johannes

author
carkat made it!(author)2012-06-12

hi,
sorry for the late reply - i was offline for a few days. all i can say is that this shield worked well, though i used a quite old arduino (arduino ng), but that should not pose a problem. the midi connector in the schematic of the forum is reversed, but the schematic in step 1 of this instructable is correct (read the remarkt on step 1 for details). also the schematic in general should not be wrong - the same one is shown on the midi - homepage at http://www.midi.org/techspecs/electrispec.php

author
pluseinn made it!(author)2010-08-17

If you are having a problem with this schematic then this might help. Don't connect anything to the pin with the 100k resistor on the drawing. This took me a week to figure out.

author
gel. made it!(author)2010-03-14

Would you know where to buy a MIDI connector? I've been having problems finding a source besides SparkFun.

author
carkat made it!(author)2010-03-14

hm - i could recommend some place but don't know if they would be helpful since i'm based in austria/europe. mabe someone else has an idea?

author
RPisces made it!(author)2009-10-07

I made this circuit, debugged it, asked in forums, and it STILL does not work!!! What could be wrong? I am using the 4N28 as above

author
carkat made it!(author)2009-10-08

uh... hard to say from a distance... maybe a few hints:
- is it really the circuit or is something wrong with the arduino (i had that problem, see above) or is the MIDI-signal not coming through properly?
- are there any solder bridges or something that looks strange?
- did you solder the DIN connector to the circuit in  the right way
- try to change the optocoupler, i once had a broken one
... anyone more suggestions?

author
RPisces made it!(author)2009-10-08

Ok I fixed it. It seems that it does not operate with the 100K resistor on pin 6 connected to ground. I removed the resistor, and left pin 6 connected to nnothing, and I am now registering serial data. Now I just have to verify the operation will be reliable...

author
daulef made it!(author)2009-09-06

I'm going to try and use this with the Auduino Synth, maybe use a proto-shield instead of etching my own though..
cheers!

author
carkat made it!(author)2009-09-06

this sounds great! would be cool if you could write an Instructable when you figured it out... i would definitely like to build one! best, carlos

author
daulef made it!(author)2009-09-08

I've got a couple of instructables in the works atm, but the midi auduino is on the cards!

author
ReCreate made it!(author)2009-07-16

Wait..Arduino's can play midi's?

author
carkat made it!(author)2009-07-16

well, at least it can recognise the MIDI signals. what you are doing with the signals then is up to you: assigning frequencies to it and sending it to an amp/speaker (=a simple synth) or driving relays (like i am going to do) are just two of a lot of possibilities :-)

author
ReCreate made it!(author)2009-07-17

Oh i get it now ;)

author
uCHobby made it!(author)2009-01-06

I recently posted about some Breadboard adapters at uCHobby including a MIDI In and MIDI Out adapters. These could be used the Arduino and feature an enable that allow for safe use along with the boot loader. I will try to have a more detailed write up on the MIDI adapters soon.

About This Instructable

37,016views

57favorites

License:

More by carkat:fail: a full tilting 3-wheeled cargo bikebuild a 2-wheel cargo bikehow to build a cargo bike
Add instructable to: