�'s Ramblings

How I Built My Custom MIDI Controller

2024-02-25T05:55:57

midichonk is my first custom MIDI controller. Its just 4 arcade buttons and 4 sliders in a custom enclosure but it’s compact, expandable/repairable, and I definitely learned some stuff putting it together. I’m far from a professional but I thought I’d document what I learned in the process in case somebody wants to use it as a jumping off point.

My Process

Planning

I’ve thought of making a MIDI controller before but when I saw my friend (shout out Digital Introspect) starting to make his own I thought it was a good time to join along. I followed his lead and bought an Arduino Leonardo which rocks for this task for a few reasons:

  • Native USB MIDI support
  • Common + Open-Source = Resources Galore
  • Capable chip with a good number of digital and analog IO pins
  • Power and program over micro USB

I also decided to buy a few components before I landed on a final design – arcade buttons, linear potentiometers, and some toggle switches that I ended up not using (yet). You could probably plan your design first but it ended up being convenient to be able to measure the components and recreate them in 3D before finalizing.

I had some much more complicated ideas than I even drew out, but I ultimately decided on the best simple starting point being 4 sliders and 4 buttons. For a first device I recommend staying within 6 analog inputs (sliders, xy pads) and 12 digital IOs (buttons, toggles, LEDs). You could do more than that on a Leonardo but it involves getting fancy.

Sketching

Once I have a direction I like to switch to a good old doodle. I sketched some options out in Procreate before switching into Fusion360 (free for personal use!):

Once I had a better sense of the layout I wanted, I measured all my components and recreated them in Fusion, including the Arduino. I laid them out and designed a simple enclosure to fit them by extruding a rounded block, splitting it in 2 parts, and using the ‘shell’ modifier on both halves. I added cutouts and supports for the sliders and buttons, and some spots to screw the case together.

I also needed a mounting location for the Arduino. I decided to stick it to the bottom and include enough wire length to where it could be opened, which I plan on doing. I initially tried a way too detailed pin design but landed on a simplified system of bent nubs that create a satisfying press fit.

Don’t forget to cut a clearance for the Arduino USB and Power. I might have missed the mark by a mm or two my first time and fixed it with a knife. The Fusion file should be updated now but it never hurts to check against your Arduino.

Testing

For testing I used a breadboard and some alligator clips and jumpers to try wiring everything together in different ways. It’s all 5v so you can kind of just fuck around. The wiring is incredibly simple, with the built in pull-up resistors enabled with a line of code all that you need to do to wire up a button is connect one lead to your chosen input pin and the other lead to ground. Toggles work about the same. Sliders require VCC in, ground, and a third lead connects to your analog input pin (A0-A5)

Once you’re wired up you can plug the Leonardo into your computer and boot up Arduino IDE and connect to your Leonardo.

Here’s some code you can use with a button connected to pin 2 to send a MIDI note:

#include "MIDIUSB.h" // this will do the heavy lifting for us

// set up variables
const int buttonPin = 2; // we'll be using the pin labeled 2 on the board
bool lastButtonState = HIGH; // HIGH is the off state with the pull-up resistor

void setup() { // this runs once
  pinMode(buttonPin, INPUT_PULLUP); // Set button pins as input with pull-up
}

void loop() { // this runs repeatedly
  bool reading = digitalRead(buttonPin); // read the state of the button
  if (reading != lastButtonState) { // if the button state has changed
    lastButtonState = reading; // save the new state
    if (reading == LOW) { // if the button is pressed
      noteOn(0x90, 60, 127); // send a note on message
    } else { // if the button is released
      noteOn(0x80, 60, 0); // send a note off message
    }
  }
}

// Helper function to send MIDI messages
void noteOn(byte cmd, byte data1, byte data2) {
  midiEventPacket_t event = {0x09, cmd, data1, data2};
  MidiUSB.sendMIDI(event);
  MidiUSB.flush();
}

You can test your MIDI controller in this stage as well by connecting to a MIDI app of your choice. I’ve been getting great use from Chataigne, with its MIDI monitor mode.

You can also use the Serial output in Arduino IDE with Serial.println("") or lit up some LED on the Arduino to make sure components worked.

Building the Case

To actually build the case I fired up the Ender 3 and printed the two halves in a nice Sakura Pink PLA+, with the flat top or bottom facing down. Settings will vary based on your printer but a pretty default setting on 0.4 nozzle with 0.2 height should fit the design well if you want to recreate it. I had a few failures with the edges curling, brims helped for adhesion.

If you don’t have a 3D printer you have some options:
– Ask a friend, you probably know someone that has one
– Buy one: they’re cheap! The Ender 3 V3 SE is fantastic for 200 new. If you have more to spend the Bambu P1P is butter smooth. And if you want to save money you can probably find an old Ender 3 for 100. The less you spend the more time you’ll spend learning about 3D printers, for better or worse.

Assembly

The assembly is pretty simple, screw the buttons in and align them. push all the sliders in and either screw them in from the top or just glue them from the bottom if you’re lazy (I’m lazy). Solder all the grounds and powers together (maybe you could solder before installing hardware but i didn’t) then connect the sliders to the analog pins, and connect the buttons and button LEDs to pins 2 through 9 in pairs, going Button A, LED A, Button B, LED B so on

I suck at soldering and you can too! Just tin the iron, tin the wire, use dupont wires for the Arduino end if it comes with headers. and test everything well before you close it all up or you’ll kick yourself

Everything You Need To Make Your Own

Tools:

  • soldering iron – you can get decent ones for as little as 10 bucks. i’ve heard the battery ones are nice for simple stuff like this
  • 3D Printer (The Ender 3 V3 SE is a great deal currently in Feb 2024)
  • wire strippers (you don’t need them need them but they sure are handy and cheap)

Testing:

Parts:

  • Any 3D Printing Filament, ~100g
  • Optional: second filament for slider caps, or buy slider caps
  • Arcade Buttons: $14.50 for set of 6, around $9.67 for 4 used
  • Sliders: $14 for set of 10, about $5.60 for the 4 I used
  • Leonardo Arduino $15 you can get these from any supplier they’re all about the same, this one was cheap
  • 22 AWG Wire: Prices vary greatly, let’s consider a conservative estimate of $2.00 for the portion used in this project.
  • 3x 2.5 screws. you can drill the screw holes to size and use any screws that fit. I used this kit $10, used parts cost pennies
  • Could also use heat set inserts for the screws. I didn’t

parts used cost: ~$35

3D Model:

Use .f3d to load in Fusion 360 or choose the file type you need

.f3d.step.3mf.obj.skp

Exported parts:

And the final code I used for my MIDI controller, which handles 4 sliders, 4 arcade buttons that light up, and also incorporates some debouncing and other checks to avoid misfires:

That’s it! That’s all it takes

Let me know if you have any questions, I’d be glad to help you get your project going. I might do a follow up with some of my ideas for a V2 (OSC, joysticks, xy, endless rotating encoders, built in screens, multiplexing, modulation…), though maybe that will have to wait until I actually make a V2.

ufffd.com