Build a USB MIDI controller
ActivitiesProjects
Assign notes to physical buttons and record a performance in a music program through USB MIDI.
Turning a physical knob or tapping a switch to shape a software synthesizer starts with a USB-capable microcontroller that translates hardware input into MIDI—the note and control instructions music software understands. Rather than following a single fixed blueprint, building a USB MIDI controller means picking the physical controls you want under your fingers, loading code that converts their readings into notes or parameter changes, and connecting the board to music software on a computer. Because the board handles the translation over USB, a homemade controller can be as minimal as a single circuit board with built-in touch pads or as involved as a 3D-printed deck with mechanical keys, knobs, and a small screen.
Three ways to shape the controls
How much wiring and fabrication the project asks of you depends on which style of controller you build:
- Built-in touch and motion: A compact board such as a Circuit Playground Express avoids wiring separate potentiometers or keys because the controls are built into the board. Seven built-in capacitive touch pads act as playable keys, while the onboard accelerometer drives modulation and pitch bend. Onboard buttons adjust pitch offset and scale, and its switch changes how the controls behave, though the board still requires its program and a USB connection.
- A bank of knobs: For hands-on parameter tweaking, a breadboard build around a Grand Central board wires 16 potentiometers to dedicated analog inputs, giving a software synthesizer or sequencer 16 continuous control (MIDI CC) knobs. Once the layout works on a breadboard, moving the circuit to a Perma Proto board or a MEGA Shield is a more advanced build option.
- Keys, knobs, and onboard editing: A 2025 KB2040 keyset design combines five CHOC mechanical key switches for triggering MIDI notes with potentiometers for continuous parameters, all housed in a 3D-printed enclosure. Adding a rotary encoder and an OLED display lets you change note assignments, MIDI channel, velocity, CC numbers, and minimum or maximum value ranges right on the device in its edit mode.
Wiring knobs and smoothing noisy readings
Every potentiometer in an analog build works as a variable voltage divider: turning the shaft shifts the voltage the microcontroller reads on its analog pin. On a Grand Central breadboard, one outer leg of each potentiometer connects to ground, the other outer leg connects to the 3.3 V rail, and the center wiper leg runs to an analog input, repeated for each knob. On the Grand Central, use the 3.3 V rail and do not use 5 V; with any other microcontroller, check its pinout and input-voltage limits before connecting power.
Raw analog readings also need scaling and cleanup in code before they feel steady in music software. On a four-knob QT Py RP2040 setup wired to analog pins A0 through A3, the board reads values from 0 to 65535 and rescales them into the ranges MIDI expects: 0 to 127 for modulation and sustain, and two pitch-bend ranges split around the 8192 midpoint (0 to 8192 and 8192 to 16383). Because an analog knob sitting right on the boundary between two steps can fluctuate back and forth, code filters out tiny changes to reduce value jitter. One approach compares each new reading against the last sent value—only transmitting when a knob moves past a threshold, such as a difference greater than 2 for modulation and sustain or greater than 75 for pitch bend—while the Grand Central code applies hysteresis to reduce jitter when a potentiometer sits on the edge between two values.
USB setup, code, and MIDI testing
Getting a computer to recognize the finished circuit starts with the cable and the board's USB configuration. Plugging a CircuitPython board in with a known-good USB data cable should mount a flash drive named `CIRCUITPY` in your file explorer or finder. On most CircuitPython boards, USB MIDI is enabled by default, but boards with tighter USB endpoint limits leave MIDI turned off until you free up space by disabling another USB device, such as USB HID. Those USB device changes live in a `boot.py` file and only take effect after a hard reset of the board.
Once USB MIDI is active, software setup follows a repeatable sequence: install CircuitPython on the board, copy the needed libraries (such as `adafruit_midi`, `simpleio`, and `neopixel` in the 16-knob Grand Central setup) into the `lib` folder on `CIRCUITPY`, and save the main script as `code.py`. Before opening a full musical session, run a MIDI monitor on your computer so you can watch the outgoing values change as you turn each knob or press each switch. From there, open a digital audio workstation, software synthesizer, or sequencer; in software with MIDI learn, select the on-screen parameter you want to control and move a physical knob to assign it.
