Introduction: Make Your Own Cheap USB MIDI Controller or Keyboard

Picture of 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

Picture of 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

Picture of 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

Picture of 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.


RogerSLO (author)2017-04-27


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,


stentor56 (author)2017-03-15

Step 1, wrong Input description!

sickfreak (author)2016-10-08

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

NikolaN19 (author)2016-06-20

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.

TabliatZ (author)2016-01-22

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

it is the same that the Thorsten Source Code :

Just add inputs

Thank you!))

Faishol27 (author)2015-09-30

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?

kyleblake123 (author)Faishol272015-11-04

Just add in a shift register.

GáborS13 (author)kyleblake1232016-01-04

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!

you will find a lot of exemples on the Internet :


JulioL2 (author)2015-06-22

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


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

SyedaB (author)2015-06-05

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


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

KadirÖ1 (author)2015-08-18

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

DavidB50 (author)2015-03-04


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!


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.



Hi AA,

With the harpsichord, you really don't need velocity, but the keyboard should be able to detect velocity, so that it will able be able to play piano samples, etc.

Thanks for your advice: I will do some research on reed switches.
¿Hablas español? ¿En qué pais vives? Es que yo 19 años en España.

Have a nice day, wherever you are!


Ho yes of course, the strings are plucked :-|

Then for the main purpose, with no velocity, it is quiet easy. You will need to make a 8x8 matrix (unless you have a chip with 61 inputs...) with 61 switches (per each keyboard). And further, for a "piano" use, it will be a little more tricky.

Vivo en Francia, pero soy "casado" con España ;-) hace muchos años

Un saludo !

abeeche12 (author)2015-02-26

Hi, do you have the hex file or the sketch that you use on the chip. Thanks.

giabzero. (author)2014-11-26

Hi there! Great man, it seems like the best solution! Can i have the parts that i will need & the schematic to solder them? thanks for now

I have made an update with the components list and a schematic file.

seamster (author)2014-11-20

Very cool! Thanks for sharing this.

About This Instructable




More by El Pajarito Manitas:Make your own cheap USB MIDI Controller or Keyboard
Add instructable to: