Raspberry Pi Pico MIDI Pedal Keyboard

Quite a number of years ago, I found an old set of organ pedals and MIDI’d them up by the crude method of wiring the pedal switches onto the connectors for the keys of an old Amstrad MIDI keyboard… It was the technology and expertise I had at the time!

I stumbled across them a few weeks back in the garage and thought it was time to bring the idea back to life with a microcontroller.

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

These are the key tutorials for the main concepts used in this project:

If you are new to microcontrollers, see the Getting Started pages.

Parts list

  • Raspberry Pi Pico
  • Pedal board or keyboard with simple switched contacts
  • 1x 33Ω and 1x 10Ω resistor (optional for serial MIDI OUT)
  • 1x 5-pin DIN socket (optional for serial MIDI OUT)
  • Solderless breadboard and connecting wires

The Starting Point

By way of introduction, this is what I was starting with:

IMG_5693

The keyboard is an Amstrad CKX100.  I believe it was one of Amstrad’s first entries into electronic music and for a typical mini-keys keyboard of the time it was ok.  But what is particularly interesting is that it comes with a MIDI OUT port!

IMG_5695

Mine was a car-boot find at the time, and some of the keys didn’t work properly (and still don’t – I didn’t bother attempting to fix it – but I might now!), but it did allow me to hook up a 25-way D-type connector that simply patched each of the lower octave of keys out to my pedal board.

This allowed my pedals, which are simple switches, nothing fancy just one wire per key – no matrix or anything in the pedals themselves – to play the keyboard “in parallel” with the built-in keyboard.

Looking online, I’ve not been able to find anything out about the pedal board (it says “made in Italy” on a sticker on the box), but this is what it looks like inside.

You might be able to see in the middle photo that the keys pull a spring connector down onto a single bar that runs the width of the board.  That is it.  One wire per key, connected to a common bus and all wires fed out to a multi-core cable.

I don’t know if it came with a 25-way male connector or not, or if that was just what I happened to have lying around at the time.  But I was able to add a matching female connector and patch it into the keyboard case to make everything nicely self-contained.  I suspect it might have come with the connector, as I don’t imagine I’d have wired it up the way it was wired otherwise… but who knows?  I can’t remember!

And after all this time (and finding a centre-negative 9V power supply), it turns out it actually all still works!

If you know anything about the origin of the pedal board, or recognise it in any way, do let me know!

The Circuit

PiPicoMIDIPedalKeyboard_bb

I’m using a Raspberry Pi Pico for this.  As the pedals are just switches, I’m literally just wiring each one into a GPIO pin and connecting the common link to GND.  I’ll be relying on the PULL UPs on the Pico which means the switches will all read HIGH when off and LOW when pressed.

I’m adding the option of a serial MIDI OUT port connected to GP0 (UART 0 TX) as described here. If you are planning to only use USB MIDI then you can skip this.  As always, I’m never convinced about the portrayal of the MIDI sockets in Fritzing, but the 3V3 OUT pin needs to go to pin 4 of the MIDI socket, and the GP0/TX pin to pin 5.

In my case, I build a simple adaptor for the 25-way connector to crimped “dupont” style jumper pin connectors.

IMG_5716

This allows me to plug the Pico into the existing 25-way socket without having to take the pedal board apart at all.

The Code

This is using a slightly simplified version of the code from this previous project: Toy Keyboard USB Matrix Decode with the Pi Pico – Part 2.

I’m using CircuitPython for its USB MIDI support.  For details of how to get CircuitPython up and running for MIDI, see this previous post.

The basic algorithm is as follows:

Set up MIDI on UART 0 and USB
Set up all the IO pins as INPUTs with PULLUPS enabled

Loop:
   Check each key and store which keys are pressed
   FOREACH note:
      IF the key was just pressed:
         Send a MIDI Note On
      IF the key was just released:
         Send a MIDI Note Off

The sending will send MIDI messages over both the USB MIDI and serial MIDI ports, so it doesn’t matter which one is connected.

Find it on GitHub here.

IMG_5721

Closing Thoughts

The concept works well!  The next thing to do would be to make it a nice neat, self-contained solution so for that I have two choices:

  • Put the Pico into a small box with the 25-way connector on one side and MIDI out and USB on the other.  This would probably work best with a TRS MIDI connector
  • Put the Pico and connectors actually inside the pedal unit.  It would need USB for power and the USB MIDI connection, with the option of either 5-pin DIN or TRS MIDI for the serial connection.

I’m still deciding.  Either way, I’d probably solder the wires directly to the Pico rather than use headers and jumper cables.

I like the idea of the pedal board having a single cable (for USB MIDI and power), but also like the idea that the pedals could be used with something else by plugging in a different 25-way connector – including the original Amstrad keyboard!

This technique can be used to add MIDI to any set of switches or keys where the number of switches is less than the number of free GPIO pins on the Pico.  If you have more, you’ll need to use some kind of IO expander or take a matrix approach.

Update: I decided.  It’s now in a box of its own!  See below.

Kevin

IMG_5724

2 thoughts on “Raspberry Pi Pico MIDI Pedal Keyboard

Leave a comment