DIY Midi Controller

by markus1423 in Circuits > Arduino

6870 Views, 25 Favorites, 0 Comments

DIY Midi Controller

Screenshot 2022-04-22 192120.jpg
Instructable MIDI Controller Demo

Music is a large part of the entertainment industry, and is enjoyed by many around the world. While music is accessible to those who enjoy it, creating music is not always easy since some users might not have access to the instruments or technology needed to create the sounds they want. Our solution for this is a DIY MIDI controller, a simple-to-use physical interface that allows you to create sounds and music virtually through your computer. MIDI controllers have been in the music industry for many years.[1] The controllers themselves can be fairly expensive.[2] The goal of this instructable is to allow users to create their own MIDI controller for a reasonable price of less than $100 [3]. The sky’s the limit when it comes to what sounds, music and beats you can create using your MIDI controller with any DJ software of your choosing.


Supplies

BOM.jpg
Micro.jpg
Arcade Pusbutton.jpg
Rotary Potentiometer.jpg
Slide Potentiometer.jpg
LEDs.jpg
22 AWG wire.jpg
Half Size Breadboard.jpg
Lexan Sheet.jpg
Aluminum Standoffs.jpg
0.625Screws.jpg
0.5screw.jpg

The following items are used in this instructable:

Electronics:


Frame construction materials:


A bill of materials is shown above. These were some of the cheapest options found, however if you find other components that you would like to add or use feel free! The only semi-permanent option here is the Arduino Micro. The MIDI controller requires native USB. Therefore, you must be careful when choosing your microcontroller as some do not have native USB. At the end of the instructable there are other microcontroller options that support native USB, and they should work wonderfully with this project.

Understanding MIDI

MIDI is a way to send musical notes digitally. It allows for communication between different electronic music devices, such as synthesizers and computers. A MIDI Controller is used to create music using digital instruments through a computer software. Often MIDI is used to play electronic imitations of real instruments, such as piano or guitar. Alternatively, MIDI can be used to create sounds that are impossible with real instruments, such as the drums, bass, and synthesizers that are common in electronic dance music. MIDI notes do not create sound themselves, they act as a form of digital sheet music, which can be played by a virtual instrument. In contrast to an acoustic instrument, which generally sounds the same, virtual instruments can sound like anything. The MIDI controller in this Instructable is capable of controlling virtual instruments on a computer through a USB cable. This makes it a useful tool for both DJs and music producers.



Cutting the Frame

Screenshot 2022-04-28 173057.png
Plate.jpg
Standoff Dim.jpg
Stand Plate.jpg

he frame consists of two pieces of rigid a material of your choosing. We recommend polycarbonate. The two plates are held together with several 2" standoffs. The following steps will show you the step by step on how to create the frame:

  • Cut out two plates measuring 4” x 6”.
  • Ensure they are the same size, and trim as necessary.
  • Mark the hole locations for the standoffs according to the CAD drawing.
  • Drill the holes for the standoffs in each plate so that they line up with eachother.

We used 8-32x.625 screws [15]. The drill bit that we advise using is a 3/16 inch bit. This is a clearance hole and will allow the screws to go in easily.

Drilling Pushbutton Holes

Pushbutton Holes.jpg
Plate PB hole.jpg

Steps to drill the mounting holes for the arcade push buttons:

  • Choose one of the two frame pieces to be the face plate.
  • Trace the locations of the button holes. A quarter is approximately the correct size for this.
  • Enusure that the buttons fit will onto the frame piece.
  • Drill the holes with one of the following methods
  • 15/16 inch or 24mm hole saw/drill bit 
  • Drilling a pilot hole, then increase the diameter with a dremel using a sanding bit.
  • Drill a pilot hole and use a router
  • Melt around the hole with a soldering iron
  • Sand down any extra material around the hole to ensure the buttons sit flush

When in doubt, drill the holes small, then increase the diameter as needed. Make sure each button has a snug fit.

Drilling Rotary Potentiometer Holes

RPOT Holes.jpg
Plate RPOT.jpg

Steps to drill the mounting holes for the rotary potentiometers:

  • Mark the location for the the potentiometers on the face plate
  • Use a 9/32 drill bit to drill the holes for best fit
  • Ensure that the threads of the potentiometer stick all the way through the front plate so that the hex nut can engage the threads.

Cutting Slide Potentiometer Slot

SPOT DIM.jpg
Plate SPOT.jpg

Steps to cut out the slide potentiometer slot:

  • Mark where the slot should be located.
  • The slides needs to be cut to a 2.5” length to allow for full operation [11].
  • The width of the slot also has to be wide enough to allow the slide to move freely [11].
  • Use a 9/32 drill bit or similar to drill a series of holes along the length of the slot and then use a file or sandpaper to smooth the edges.

Drilling Slide Potentiometer Mounting Screws

SPOT Mholes.jpg
Plate SPOT Mholes.jpg

Steps to cut the mouting slot for the slide potentiometer:

  • Mark where the mouting holes should be located.
  • Drill the mounting holes with a #28 bit or larger.
  • The screws used in the slide are 6-32 screws, so it will need a hole big enough for those screws at 0.131” [16].

Mounting Components

Pot Installed.jpg
Fully Assembled MIDI.jpg

Steps for mouting the slide potentiometers the controller:

  • Mount the slide potentiometer using a #6-32 screw on each corner [11].
  • Tighten just enough for a snug fit, but not enough to bend or break the potentiometer.
  • The screws should thread into the potentiometer holes directly.

Steps for mounting the rotational potentiometers

  • One by one insert the potentiometers into the mounting holes.
  • Tighten the accompanying nut onto the top of the stem.
  • Ensure the nut is very tight so that it does not loosen while using the potentiometers.
  • Spin each potentiometer as far counter-clockwise as possible.
  • place the provided cap so that the notch points toward the 7 o’clock position.

Steps for mounting the arcade pushbuttons

  • Snap the buttons into the dremeled holes.
  • Each button should click into place.
  • Ensure a snug fit.
  • If any buttons rattle this is an indication that the hole was made too large.
  • Tape, adhesive foam, or hot glue can be used to fill the excess space and hold the button in place.


Soldering

Pot Solder.jpg
Arcade Solder.jpg
SPOT Solder Ponts.jpg

Steps for soldering the inputs to the board:

  • Use color-coded wire to assist with identifying correct connections.
  • The potentiometers have 6 pins[10], however you only need to make solder connections from the three pins shown to the microcontroller.
  • Use the bottom 3 pins were to for best clearence on the rotational potentiometers.
  • Connect the right pin of each pin to +5 from the microcontroller.
  • Connect the middle pin of each potentiometer to a unique analog pin between A1 and A4 of the microcontroller.
  • Connect the left pin to ground from the microcontroller.
  • Connect one pin of each pushbutton to ground
  • Connect the remaing pin of each pushbutton to a unique digital pin between D5 and D12 on the microcontroller

Wiring and Frame Assembly

Final Wiring Schematic.jpg
Connections to micro.jpg

A schematic showing the connections of the MIDI controller is shown above. This schematic follows the layout of the actual MIDI controller in terms of pushbutton and potentiometer layout. The schematic is color coded and provides the pin connections of each component next to the components.

The connections to the Microcontroller are also shown.

Connection steps:

  • Peel the away the film on the bottom of the breadboard to reveal the adhesive.
  • Mount the breadboard to the bottom plate of the MIDI frame.
  • Screw the standoffs into the top plate.
  • Mate the two halves of the controller and put the screws in the bottom plate side.

Upload Code

Upload Soft.jpg
Select Board.jpg
Select Com.jpg
Upload.jpg

Coding instructions:

  • Download the Arduino IDE from the Arduino website [18], or launch the Arduino Web Editor [19].
  • Connect the Arduino to a computer with a USB cable.
  • Download the supplied program below.
  • Open the program in the Arduino IDE.
  • From the toolbar at the top of the editor, select Tools -> Board -> “Arduino Micro”.
  • Then select the Tools -> Port -> “COMX” where X is the port your Arduino is connected to.
  • In the event there are multiple options, it may take some trial and error. It will almost never be COM3.
  • Then press the upload button to put the program onto the Arduino itself.

The Arduino is now able to be used with any music software as a MIDI input device.

#include "MIDIUSB.h"


// struct for buttons
struct button{
  uint8_t port;
  bool pressed;
  uint8_t count;
};


// struct for potentiometers
struct pot{
  uint8_t port;
  uint8_t last;
};


button buttons [8];
pot pots[4];


void setup()
{
  // declaring each button port sequentially
  for(int i=0; i<8; i++){
    buttons[i].port = 12-i;
    buttons[i].pressed = false;
    buttons[i].count = 0;
    pinMode(buttons[i].port, INPUT_PULLUP);
  }


  // declaring each potentiometer sequantially
  for(int i=0; i<4; i++){
    pots[i].port = i+A1;
    pots[i].last = 0;
  }
}


void loop()
{
  // button press logic, checkes each button in a loop with debounce
  for(int i=0; i<8; i++){
    if(!digitalRead(buttons[i].port)){
      if(!buttons[i].pressed && millis() - buttons[i].count > 2){
        uint8_t note = buttons[i].port+31;
        midiEventPacket_t noteOn = {0x09, 0x90 | 1, note, 127};
        MidiUSB.sendMIDI(noteOn);
        buttons[i].pressed = true;
      }
    } else {
      if(buttons[i].pressed == true){
        uint8_t note = buttons[i].port+31;
        midiEventPacket_t noteOff = {0x08, 0x80 | 1, note, 0};
        MidiUSB.sendMIDI(noteOff);
      }
      buttons[i].pressed = false;
      buttons[i].count = millis();
    }
  }


  // potentiometer reading logic, checkes each potentiometer for moving a certain threshold to prevent jiggling
  for(uint8_t i=0; i<4; i++){
    uint8_t val = analogRead(pots[i].port)*(127.0/685.0);
    if(val > 127)
      val = 127;
    if(abs(val - pots[i].last) > 1){
      pots[i].last = val;
      midiEventPacket_t event = {0x0B, 0xB0 | 1, pots[i].port, val};
      MidiUSB.sendMIDI(event);
    }
  }
  MidiUSB.flush(); // send MIDI data via USB
}

Troubleshooting

At this point, we have to accept the harsh reality that sometimes things don’t work as they were intended to. For this reason, we have put together some brief troubleshooting procedures that we hope will guide you through whatever hiccups you might have encountered.


  • Loose/Wobbly User Inputs: If you find that the buttons, knobs, or slider are a bit loose or move around from their mounting points on the controller, take your screwdriver and tighten the hardware fastening the input to the frame. You should tighten the screw until the component is held securely to the frame. Be careful not to tighten the screw any more than necessary to prevent damage to the frame.
  • Microcontroller NOT Receiving Power: If your micro does not power on when you connect it to your computer, there are two things you can try. First, see if your microcontroller will power on when connected to a different USB port. If this does not work, you can try to use a different USB cable to power your microcontroller. If this also fails, then your last option is to return your faulty microcontroller to the vendor [7] and acquire a new one.
  • Microcontroller NOT Able to Communicate with Host Device: If this is your issue, there are a couple things you can check on the Arduino IDE to try and resolve it. First, you must ensure that the right board type was selected. The board type you should select reads “Arduino Micro” and is found under Tools -> Board from the toolbar at the top of the Arduino IDE. Also, navigate to Tools -> Port, and ensure that the right COM port is selected. If you are using a PC, You can check what COM port the Arduino is connected to by going to Device Manager on your computer and clicking the drop-down menu for “Ports”. If the correct board type and COM port have been selected and your micro still cannot communicate with your computer, then your last option is to try connecting it to a different USB port.
  • Microcontroller NOT Able to Receive Signals from User Inputs: The push buttons on the MIDI controller frame are connected to digital input pins on the micro. The knobs and slider are connected to analog input pins on the micro. If your micro is not receiving signals from one or more buttons, then double-check that you have made your connections to the right digital pins on the micro. For the knobs and slider, make sure you have made connections to the correct analog pins on the micro. If you have verified both these things and the problem persists, then you must assume that one or more of the digital/analog input pins on the micro are dead. See if you can reconstruct the connections to the micro while avoiding using any dead pins in the process.
  • User Inputs NOT Producing Intended Output: This is similar to the previous issue discussed. If you are sure that you have made proper connections to appropriate functional pins on your microcontroller but your user inputs are still not producing their intended output, then the issue might lie with the hardware. Check all of the soldering joints on the buttons, knobs, and slider to make sure that there is a valid electrical connection. You can re-solder the joints if necessary. If this doesn’t work, verify that the program is running correctly, try a different USB port, or both. If you still find that a button, knob, or slider is not functioning properly, then you must replace that component if all other troubleshooting procedures have been attempted.
  • Microcontroller NOT Able to Send MIDI Signals to Host Device: If your MIDI controller is not able to produce music from your computer, there are a couple things you should try. First, check the configuration of the DAW to make sure the micro is properly recognized. Next, ensure that the program was actually uploaded to the controller. If that doesn’t produce any results, then try a different USB port on your computer.


Using MIDI Controller

MIDI controllers are a dynamic and customizable tool in the arsenal of any DJ or music producer. Most digital audio workstations will have a menu to allow for configuration of MIDI input devices. You can find the steps for Ableton live at this link [16] and tutorials for many other popular DAWs on their websites or in their user manuals. MIDI controllers can be used to play instruments such as drums, control effects and parameters such filters, and trigger samples and clips during live performances.

Conclusion

If you made it this far, congratulations! You now possess an instrument with endless musical capabilities. We genuinely hope the process has been as enjoyable and informative for you as it was for us. With your slick new MIDI controller, you are equipped to thoroughly entertain any crowd, or just jam out and experiment with sounds on your own. In the end, the most important thing is to have fun and get creative! Enjoy!!



References

[1]“History of MIDI - what is MIDI?,” Hosa, 08-Feb-2021. [Online]. Available: https://hosatech.com/press-release/history-of-midi/#:~:text=When%20Was%20MIDI%20Invented,over%20a%205%2Dpin%20cable. [Accessed: 22-Apr-2022]. 

[2]“Home,” MSpot The Spot for Musical Instruments Audio Equipment. [Online]. Available: https://www.mspot.com/how-much-do-electronic-keyboards-cost/#:~:text=Keyboard%20MIDI%20Controllers,-MIDI%20controllers%20are&text=Moreover%2C%20you%20use%20them%20to,cost%20about%20%24100%2D%24400. [Accessed: 22-Apr-2022]. 

‌[3] D. Huston, “Project Description,” Jan. 19, 2022.

[4] “Amazon.com: Arduino Micro with Headers [A000053] : Electronics,” www.amazon.com. https://www.amazon.com/Arduino-Micro-Headers-A000053-Controller/dp/B00AFY2S56/ref=asc_df_B00AFY2S56/?tag=hyprod-20&linkCode=df0&hvadid=309707619534&hvpos=&hvnetw=g&hvrand=17408550822334472063&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9016722&hvtargid=pla-634201301477&th=1 (accessed Apr. 22).

[5] “Amazon.com: Avisiri 10x Arcade Buttons 24mm Push Button Replace Switch for Sanwa OBSF-24 Arcade Joystick DIY Parts Video Games Mame Jamme Black : Video Games,” www.amazon.com. https://www.amazon.com/Avisiri-Buttons-Replace-OBSF-24-Joystick/dp/B07X242Z4D (accessed Apr. 22, 2022).

[6] “Taiss / 5pcs 10K Ohm 6 Pins Split Shaft Rotary Linear Dual Taper Audio B Type Potentiometer, Volume Control Potentiometer B10K + 5pcs Knob (Black): Amazon.com: Industrial & Scientific,” www.amazon.com. https://www.amazon.com/Taiss-Rotary-Linear-Potentiometer-Control/dp/B07DJ7H1YC/ref=pd_lpo_1?pd_rd_i=B07DJ6L6J4&th=1 (accessed Apr. 22, 2022).

[7] “DAOKI 5PCS 10K Logarithmic Slide Potentiometer Analog Sensor 3.3V 5V Dual Output Log Slide Pot Module for Arduino AVR Electronic Block with 4PCS Potentiometer Cap: Amazon.com: Industrial & Scientific,” www.amazon.com. https://www.amazon.com/DAOKI-Logarithmic-Potentiometer-Arduino-Electronic/dp/B08SLPV4VD (accessed Apr. 22, 2022).

[8] “Amazon.com: (100 Pcs) MCIGICM 5mm LED Light Diodes, LED Circuit Assorted Kit for Science Project Experiment (Multi-Colored - 5 Color) : Industrial & Scientific,” www.amazon.com. https://www.amazon.com/MCIGICM-Circuit-Assorted-Science-Experiment/dp/B07PG84V17 (accessed Apr. 22, 2022).

[9] “Amazon.com: BNTECHGO 22 Gauge PVC 1007 Solid Electric Wire Black 25 ft 22 AWG 1007 Hook Up Tinned Copper Wire : Industrial & Scientific,” www.amazon.com. https://www.amazon.com/BNTECHGO-Electric-Tinned-Copper-Yellow/dp/B07JNB8YR3/ref=sr_1_1_sspa?keywords=22%2Bawg%2Bwire&qid=1650481041&refinements=p_36%3A100-700&rnid=1243644011&sr=8-1-spons&spLa=ZW5jcnlwdGVkUXVhbGlmaWVyPUEyTVdKU1o4TlpaVVM5JmVuY3J5cHRlZElkPUEwMzU1MjQ4M0ZBUVBaNjU0NFNOSCZlbmNyeXB0ZWRBZElkPUEwNDU4MDc2MUlCMVNPVVg2TlNJQSZ3aWRnZXROYW1lPXNwX2F0ZiZhY3Rpb249Y2xpY2tSZWRpcmVjdCZkb05vdExvZ0NsaWNrPXRydWU&th=1

[10] “4000,” 4000 Pololu Corporation | Prototyping, Fabrication Products | DigiKey Marketplace. [Online]. Available: https://www.digikey.com/en/products/detail/pololu-corporation/4000/11586861?utm_adgroup=Solderless+Breadboards&utm_source=google&utm_medium=cpc&utm_campaign=Shopping_Product_Prototyping%2C+Fabrication+Products&utm_term=&utm_content=Solderless+Breadboards&gclid=Cj0KCQjwpImTBhCmARIsAKr58cy4RPT_-0rhbM_kTfWLge5kE6773GOZb99jmr540KF_srEJUYjIj44aAprEEALw_wcB. [Accessed: 22-Apr-2022].

[11] “1/4’’-Thick 6’’ x 12’’ Clear Polycarbonate Lexan Sheet,” estreetplastics.com. https://www.estreetplastics.com/1-4-x-6-x-12-Clear-Polycarbonate-Lexan-Sheet-p/3002500612.htm (accessed Apr. 22, 2022).

[12] “1/16’’-Thick 12’’ x 12’’ Clear Polycarbonate Lexan Sheet,” estreetplastics.com. https://www.estreetplastics.com/1-16-x-12-x-12-clear-polycarbonate-lexan-sheet-p/3000601212.htm (accessed Apr. 22, 2022).

[13] “2221 Keystone Electronics | Hardware, Fasteners, Accessories | DigiKey,” www.digikey.com. https://www.digikey.com/en/products/detail/keystone-electronics/2221/303793 (accessed Apr. 22, 2022).

[14] “Black Star Drive Screws, 8-32 x 0.625" (5/8"), 100 pack, T15 Torx for VEX Robotics,” Robosource.net. https://www.robosource.net/robot-parts/screws-hardware/steel-screws-nuts/black-star-drive-screws/441-black-star-drive-screws-0625 (accessed Apr. 22, 2022).

[15] “90272A144 TubeDepot | Hardware, Fasteners, Accessories | DigiKey Marketplace,” www.digikey.com. https://www.digikey.com/en/products/detail/tubedepot/90272A144/10488405 (accessed Apr. 22, 2022).

[16] “Using MIDI controllers with live - ableton.” [Online]. Available: https://help.ableton.com/hc/en-us/articles/360011853159-Using-MIDI-controllers-with-Live. [Accessed: 22-Apr-2022].

‌[17] “Pioneer DJ CDJ-2000NXS2 Professional DJ Media Player,” Sweetwater. https://www.sweetwater.com/store/detail/CDJ2000NXS2--pioneer-dj-cdj-2000nxs2-professional-multi-player-black (accessed Feb. 13, 2022).

[18] “Software,” www.arduino.cc. https://www.arduino.cc/en/software

[19] “Arduino Create,” Arduino.cc, 2019. https://create.arduino.cc/editor (accessed Nov. 26, 2019).