MIDI Shield

This can be the basis for all sorts of Arduino projects that rely on MIDI, Musical Instrument Digital Interface.

Although MIDI is getting a bit long in the tooth now there are still many instruments and interfaces that use it, and a MII interface is something that is easy to do with an Arduino. Basically a MDI signal looks like a normal serial signal but with different voltage characteristics  and a non standard baud rate. As most Arduinos have only one serial port, if you want to make something that talks or listens in MIDI you have to share that port with the normal programming, uploading and printing debugger port. While you can simply wire the serial port up to a MIDI interface you will find that when you are up loading your sketch you are also sending junk into your attached MIDI device. Also when you are listening to something on the MIDI input this can cause havoc with uploading. The simple answer is to unplug any MIDI device when uploading but that can can be a bit tiresome. So I have included a programming switch that effectively removes the MIDI interface connection into he Arduino when you are programming or debugging.

The schematic is quite straight forward, on the transmit side the serial output is fed through a resistor to the base of a PNP transistor. These are sometimes called “upside down” transistors because a high voltage into it makes it stop conducting and a low voltage makes the collector / emitter conduct.

MIDI software is quite simple and on the send side is just a matter of setting the baud rate to 31,250 Baud and sending the bytes in your MIDI message. These are normally things like note on or note off and consist of three bytes. The first identifies the message and the channel you want to send it over followed by the note number, 0 to 127, followed by the note velocity again 0 to 127.

The receive side is slightly more complex in that you have messages that consist of different numbers of bytes, you have to split these out or as we say parse them. You are best looking at an example so MIDI_Shield.ino.zip shows how to transmit and receive.

Making an

Arduino MIDI Shield

The output is then channeled through the MIDI receiving device through two 220R resistors. In effect this is a current output as opposed to the more normal voltage output. On the receive side the signal from the MIDI transmitting device is passed through a 6N139 opto isolator. This is basically a LED and a photo transistor in the one package the only connection between the sending device and the arduino is a light path. There is a resistor to protect the input from too much current and a diode to protect against reverse voltage if for example you wired the MIDI leads up incorrectly. The photo transistor output is simply pulled up and fed into the receive pin of the Arduino.

One problem with MIDI projects is that people tend to wire the sockets the wrong way round. Note that these sockets are shown as viewed from the back, that is the side you wire up to. The sockets I used were PCB mounting and they make a good neat job. The one thing not shown on the schematics is the offset header sockets to allowing you to access the other pins on the Arduino, you can see this on the photos. Also the LED is just in parallel with the pin 13 LED on most boards, this is optional.