Make Your Own Cheap USB MIDI Controller or Keyboard





Introduction: Make Your Own Cheap USB MIDI Controller or Keyboard

I was looking for an USB MIDI controller device (or interface) for music applications like piano or organ keyboard or pedalboard. After some research, I wanted to go to a more "homemade" solution. My choice has finally been oriented to a microcontroller board development like the Arduino boards and I choose a Teensy Development Board as it can natively use an USB MIDI library (teensy web site).

It was very useful to make some tests with MIDI softwares and write some MIDI "hello world" software (via some sketches of the arduino IDE). But as I want to keep board "free" and I don't want to sacrifice it in a permanant device, I looked into a cheaper solution.

My Goal:

- make it cheap / low cost
- with the easier architecture possible (only one MCU)
- can communicate through the USB port directly (whithout a MIDI-to-USB conversion step)
- recognise by a Computer as a stand alone MIDI device
- easy to build (at worst, a soldering iron)
- powered by the USB port with no external power source

The result:

It looks like an Arduino on a Breadboard based on an Atmega328p MCU (atmel site), communicate directly through the USB port thanks to the V-USB software-only implementation (V-USB site), and cost only about 8€ (10$) to build (for electronical components)

Step 1: Architecture / Principe

The device has no aditionnal chip and communicate directly through the USB port.

I use the analogic/digital inputs to generate events. The management of these events and the conversion in the USB MIDI messages are treated by the software embed in the Atmega MCU.

Step 2: My Own AVR USB Device

My kit is based on the USnooBie development Kit (USnooBie):

The USnooBie is a microcontroller kit that does not require any sort of AVR programmer or USB-to-serial converters to load and run compiled code. It's hardware design allows the user to develop low cost USB devices with Atmel's AVR ATmega microcontrollers. It can also be used to develop projects which are not USB devices. It is even compatible with Arduino.

I have adapted the schematics and remove the voltage regulator and kept only the zener diodes to limit the D+ and D- voltage (see the schematics image). All these specifications are detailed on the V-USB Obdev site (V-USB Obdev)

The needed components are the following:
- 1x Atmega328p
- 1x USB connector
- 1x 12MHz crystal
- 2x 3.6V zener diode
- 2x 22pF ceramic capacitor
- 1x 100nF ceramic capacitor
- 1x 4.7μF electrolytic capacitor
- 1x 1.5kΩ resistor
- 2x 68Ω resistor
- 2x mini push button switch

The first success step is to turn the device in the USBasp mode by activating the bootloader.

The use of the bootloader is not mandatory but it is very useful as il allows to flash the future SW directly through the USB port (FTDI or AVR Programmer are not needed any more)

Step 3: Programming the Midi Software

The bootloader mode allows to consider the device as an USBasp programmer. In this mode, you are able to upload softwares directly to the MCU without an extra FTDI or Programmer. This mode is also compatible with the Arduino IDE (exemple).

In my case, I didn't succeed to use directly any MIDI library with Arduino IDE sketches, so I came through a more basic way (with AVRdude command lines) and I was inspired by 2 work:

I made some modifications in the C code to make it compatible with the Atmega328 MCU (pin numbers, analogic/numeric - input/output, etc.) and the USnooBie configuration (mainly the D+ and D- pin assignment).

Once the USB divice is reseted, it is recognized as an Audio Device.

Step 4: The Result

You can see the result in this short video.

The device is recognized as a MIDI controller.

In my case, I assigned it to a Piano keyboard and I send “Note On” and “Note Off” MIDI message by pressing and releasing some switches.



    • Pocket-Sized Contest

      Pocket-Sized Contest
    • Pro Tips Challenge

      Pro Tips Challenge
    • Science of Cooking

      Science of Cooking

    We have a be nice policy.
    Please be positive and constructive.


    You forgot the pullup resistor on the reset pin.




    Will this work on OS X (El Capitan, Sierra)?

    I would only need two midi buttons with the Momentary (push?) mode.

    Button pressed is midi ON, button released is midi OFF.

    Thank you,


    Step 1, wrong Input description!

    Hello everyone, I having a problem installing everything, the drivers, v-usb, and i don't know how to do it properly, could anyone help me? There is any video or a very detail tutorial in order to install the software and the drivers? Im using Linux

    Thank you

    Hey, just here to tell you that I see a tiny mistake which I can't look away from.
    In your last image you switched inputs.
    General buttons, as I know, are digital and potentiometers are analog. Not otherwise, even though it would kind-of be able to work, but not as intended.

    Don't see source code(( Can I see source?

    Nice tutorial! I've been looking for! But, can I add more button? because in your demo you only have 5 button I want have 12 button. but how can I do it?

    Would you care to explain please, how exactly is this done? For example using CD4067s - those are widely available, inexpensive and suitable AFAIK, I just have no idea how to implement it in the circuit above. Thanks!