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.



    • Make it Glow Contest 2018

      Make it Glow Contest 2018
    • Toys Contest

      Toys Contest
    • PCB Contest

      PCB Contest

    26 Discussions


    Tip 9 months ago

    You forgot the pullup resistor on the reset pin.


    1 year ago


    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,



    1 year ago

    Step 1, wrong Input description!


    2 years ago

    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


    2 years ago

    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.


    3 years ago

    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?

    4 replies

    Reply 2 years ago

    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!


    3 years ago on Introduction

    Hola estoy intentando hacer un acordion Midi pero no se mucho de Atmel studio y no se como hacer el bootloader para que el atmega328 sea reconocido como un dispositivo Midi no se si podrias subir el Hex para cargarselo a mi atmega

    Saludso desde Tijuana

    1 reply
    El Pajarito ManitasJulioL2

    Reply 2 years ago


    my HEX is linked to my project (a test with 7 keys). It is just a proof of concept and is not applicable directly


    3 years ago on Introduction

    Hey friend.! Can you please re-make the circuit. I want to build it like module. So, your new circuit will specify which pin is analog in/digital in and outs. Like an arduino have

    1 reply
    El Pajarito ManitasSyedaB

    Reply 2 years ago


    You can find the pins caracteristics from the Atmega Datasheet like this :


    3 years ago on Introduction

    Just the tutorial I've been looking for! Definitely gonna make use of this.


    3 years ago on Introduction


    Very interesting! I am now planning to make a digital keyboard using a "real" harpsichord keyboard (i.e., one made by a professional harpsichord builder).

    I am looking for an appropriate type of midi sensor system; Perhaps yours would be good for such a purpose? If you think you may be interested in a business collaboration (no need for investment on your part), please contact me:

    David Bolton

    dboltoncreations AT

    Have a nice day!


    1 reply

    Hi David,

    Mostly in this device, people are using reed switches. It is robust and quiet.
    understand that with harpsichord you have to manage the velocity ?
    (like a piano keyboard). In this case, you will need 2 switches per key
    to calculate the typing speed. Then the speed is sent through the midi
    message to the computer, to a harpsichord simulator software.