MIDI In-Out Half-Shield

I have an idea for a project that only uses part of the Arduino’s IO so that got me wondering if I could fit a full MIDI shield into half the space of a full shield.  Its more of an idle curiosity really as shields will stack and as I’ve already shown MIDI circuitry can be incorporated quite easily into easily hooked up modules.  But once the idea was planted I thought I’d give it a go.

Warning! I strongly recommend using an old or second hand keyboard for your MIDI experiments.  I am not responsible for any damage to expensive instruments!

The shield is designed for an Arduino Uno.  If you are new to Arduino, see the Getting Started pages.

Parts list

  • Arduino Uno
  • 2x 5 pin DIN sockets
  • 4x 220Ω resistors
  • 1x 4K7 resistor
  • 1x 1N914 diode
  • 6N138 optoisolator
  • 1x “right angle” DPDT or DPST pcb mounted switch
  • 2x 6-way “long pin” female headers
  • 2x 6-way male headers
  • 1x 3-way female header
  • 5x single pin male headers
  • 5x single pin female header/socket
  • Proto-board – 20×6 holes
  • Proto-board – 20×7 holes

The Circuit

Arduino-DIY-MIDI-Shield_bb

This is the same basic MIDI circuits used already for MIDI in and MIDI out but I’ve split it over two 20 hole wide proto-boards.  20 holes allows it to match up with the width of the Arduino’s pin headers.  The lower board is 7 holes wide and the upper board is 6 holes wide.  The diagram above gives three views of the main, lower (7×20) circuit board, and one view of the additional, upper (6×20) board that will contain the two MIDI sockets.

Here are some pictures of what I’m aiming for so you get the idea.

And this is how I’m expecting the two proto boards to sit on an Arduino.

Arduino-DIY-MIDI-Shield-Alignment_bb

Although the board links to A0-A5 on one side and D0 to D5 on the other, it only actually requires linking up to RX/TX (D0 and D1), 5V and GND.  This is another one of those builds that evolved a little as I was making it.  One change relates to power as I’d initially imagined have two jumper wires between the half-shield and the power pins, but then I realised I could use the VCC and GND connections from the ICSP header, so changed and added a 3-way female header on the underside of the bottom board to plug into the outer 3 pins of the ICSP header.

MIDI will interfere with programming the Arduino as both functions try to use the RX/TX lines, so I included a switch to disable the MIDI shield when programming.  The circuit shows two switches, but I actually grabbed a DPDT switch.  My switch didn’t have pins at the standard proto-board hole spacing (2.54mm), so I cut off the two spare terminals (making a DPST switch) and drilled out two of the holes to allow me to fit it in. I was initially hoping for less space between the boards, but the switch body was quite wide.

Another change – initially I was planning on soldering the two boards together and use long pins from the top board right down into the Arduino. But the size of the switch meant that was no longer feasible, so I went for long-pin female headers on the bottom board and let the top board plug into those.

There are five connections required between the top and bottom boards.  Two for MIDI in and three for MIDI out.  I added extra pins in the appropriate place on the top board and paired them up with matching single-pin sockets on the base board.  The sockets are actually designed for receiving chips or other components, so I had to use thin pins to connect.

That is pretty much it.  Here are some photos of the finished boards.

And here it is joined up and mounted on an Arduino Uno.

The Code

This is a hardware build so requires no code other that whatever application you decide to use it for!

But in order to test it, I wrote a simple MIDI effects function.  The sample code will receive a note on the MIDI in and send it to the MIDI out along with another note a fixed interval apart.  You can set the interval to anything you want.  I used 7 in my initial tests, which is a fifth higher, which makes for a very medieval sounding output!  Other useful intervals could be 12 (an octave higher) or -12 (an octave lower).

Find it on GitHub here.

Closing Thoughts

As I said at the start there are already many options for MIDI interfaces to Arduinos, but it was interested to see that I could squeeze both MIDI in and out into just the space occupied by 6 pins of an Arduino header.

This is a little wasteful – D2 to D4 and A0 to A5 are not available for direct use.  An enhancement might be to route these out for use.  Of course it is entirely possible to stack this on top of another shield … but if you are doing that you could probably use a proper MIDI shield anyway.

This worked ok as a proto-board, but it is crying out to have a custom PCB made for it. It would also be useful to see how far the gap between the boards could be shrunk.  It is possible to get some rather small switches for example that might be worth looking into.

I’m also wondering about create a more sophisticated set of MIDI effects in code that I could play with.

Kevin

 

Leave a comment