Sunday, October 16, 2011

Atmel Attiny45 / Attiny85 based USB MIDI controller

Today I made a MIDI controller out of an Attiny45 and a potentiometer.

This project implements the V-USB firmware from Objective Development to emulate a class compliant audio / MIDI stream device using an Atmel AVR microcontroller. It is based on the V-USB-MIDI project by Martin Homuth-Rosemann and partly on the 4-key-keyboard project.

The nice thing about this project is that it takes advantage of the internal RC oscillator of the Attiny and therefore not even needs an external crystal.

Hardware needed:
  • 1x Atmel ATTiny45-20PU or ATTiny85-20PU microcontroller
  • 2x Diodes (1N4148)
  • 2x 68 ohm resistors
  • 1x 1.5K resistor
  • 1x 0.1 uF capacitor
  • 1x 10K potentiometer
  • 1x USB cable with USB-A plug
  • Programmer for Attiny45 / 85


The Fuses have to be set to 0xC1 (low), 0xDD (high) and 0xFF (ext.). 

The PID and VID used in this project are sponsored by Objective Development.
AVR is a registered trademark of Atmel Corporation.

Download the project and the .hex file here. It should work equally well on both the Attiny45 and the Attiny85.


  1. Greetings from Estonia.

    Nice project. Simple and cheap. U inspired me to take out my tools and work with my midi project again. What is been sleeping 1,5 years. But can u send me your project files? The link above is death.


  2. Thanks! It's great to hear that this little experiment is useful for someone. Sorry for the dead link, I didn't know that the file hoster I used deletes files after a certain period of time. I updated it, now it should work again.

    Greetings from Germany,


  3. Hi
    Nice project.
    How can i complie the project file under windows?
    I tryed both WINAVR and AmtelAVR with no success

    1. Hi! Sorry for not replying right away. I am using an avr plugin for Eclipse, so I don't have any experience with WINAVR and AtmelAVR. But as far as I know WINAVR has a makefile template which should be easily adapted to this project.

  4. I had no problems with understanding the code, but I'm sort of a noob when it comes to electronics. I figure I could replace the 68-ohm resistors with 100-ohm right? Or, would that lower the voltage of the data lines too much?

    BTW, this is an awesome project! I had been looking for a well documented and useful example just like this to learn from.

    1. Hi! Thanks! Unfortunately I still haven't had the time to make something useful out of it.

      The 100 ohm resistors work fine. Somewhere I read that "68" is an "educated guess" and anything between 30 and 100 ohms should work well enough. Reportedly you also can leave out the zener diodes and use a 2.2k ohm resistor instead of the 1.5k one, but as my electronics knowledge is also very limited I can't say anything about that. ;-)

    2. It's just "diodes" instead of "zener diodes", of course.

    3. Thanks for the reply. This has proven to be a good learning experience for me. I have a few thoughts I'd like to share.

      It works well with your circuit (I built it the same day I left the previous comment), but I occasionally got a "USB device not recognized" error in Windows. This was fixed by adding zener diodes (3.6v 250mw) between the data lines and ground.

      USB doesn't like anything above 3.6v or below 3v. Since we're using such small current (20ma I believe) and the response curves of real world diodes is not perfect, the real voltage out of the data lines is about 3.3v at 20ma (what we need).

      I also used a 10k resistor for pull-up instead of the 1.5k one because I couldn't find any and because that's the usual value I've seen so I hoped it wouldn't matter. It worked fine. :-)

      I'm thinking of putting this circuit to use as a MIDI guitar pedal. I could probably put the guts in an old, broken pedal I have. I just need figure out how use the hall effect sensor inside it.

      I use Amplitube 3, so this should map nicely to the virtual wah, volume, etc. pedals in the software. I'm also considering implementing a mode switch function where I can use the same physical pedal to control multiple pedals in various ways. e.g. virtual pedal #1 is inverted and pedal #2 is not, deadzones, auto-oscillation, etc.

      Thanks again, man! I now have something to keep me busy!

    4. You're welcome! Thanks for sharing your findings!

    5. is it possible to program these hex files into the attiny using arduino as isp?

  5. The same question:

    "is it possible to program these hex files into the attiny using arduino as isp?"

    thanks in advance

    1. It should work. I've never used the Arduino as an ISP, but as far as I know you can use avrdude (the WinAVR uploader program) together with Arduino ISP.

  6. hello,

    Is it possible to update the link for download, it seems broken link without any progress for long time.

    1. Hm, for me the link still works. Perhaps you just have to try again.

  7. Can you give us the source code of the attiny? I wonder if i can make a 4 pot controller... thank you

    1. Hello Alex! The source code is part of the ZIP file I posted the link to in the last paragraph of the article (just click in the word "here" ;-) )

  8. Is this a standard midi compliant device? What I mean is, do pins 3 and 6 which are currently unused allow for standard midi to be entered into them and this will be passed onto the host computer through the attiny chip? Has anyone else taken this and developed it further? I'm finding it sad that there are very few solid projects on the net that will let me turn an attiny into a near midi class compliant device. There is a project on the web that converts your whole Arduino into a midi device but I don't want to do that. I want to make a cheap midi to usb adapter for a foot controller project I have in mind. Any help would be appreciated. As of now, I see my only solution is to buy one of those ultra cheap usb to midi adapters on ebay and use that instead. They only cost £3.

    1. Hello Grant, if I understand you correctly you just want to connect a "good old midi cable" to your computer using usb. In that case, I would go for the ebay option. Although the attiny is recognized as a standard midi compliant device by the host you connect it to, I don't think it has enough processing power left to read serial midi data (which is transmitted with about 31 kbps) on pins 3 and 6.

      Can't you just connect the potentiometer in the foot pedal to an Atmel avr mcu and also use the V-USB-MIDI firmware?

  9. Hi Thorsten, thanks for the reply. Basically I'm obsessed with midi foot controllers. I've made them out of all kinds of things and I just keep finding new ways to create them and improve their design. I've made a foot controller from a wireless x-box 360 controller using Flowstone. Flowstone is amazing software you should check it out. Right now I'm exploring Arduino and I really like what it can do. It's not hard to learn, but it's time consuming for sure. I've invested in some cheap peizo sensors that I plan to use to make a combination midi foot controller and drum pad. I'm into loop guitar so I'll be able to trigger drums with my feet. It just seems so natural I don't know why I didn't think of it before.. Probably because I thought it was something I wouldn't be able to do unless I tore apart one o those new tiny midi keyboard/drumpad gadgets that are getting pretty popular.. and I have a thing about destroying stuff that's working..

    Anyway, I've decided to use the cheap ebay usb to midi adapter and strip it down to it's bare circuit board. I've also recently discovered something new. and that's the Arudino Nano. Not the standard one, but the one that has no usb to serial chip. they are really cheap from china at about £2 each. basically it's an Atmel 328p chip in a small chip design. you have to solder on any pins you want but they're included. So it's really economical and smart package. It will let me have several midi drum pads and several foot controllers..

    I'm also kinda interested in midi controller clothing. Sounds ludicrous I know.. but the idea I have is to have a live show in which I hand out to the audience all these midi vests that they can put on and on each of the breasts are three drum pads all connected wirelessly to a computer.. and so you hand out the first one and that person starts to make a rhythm.. and then you coax someone else to put on the next one and they start to add to the rhythm mix and maybe you hand out two more and the whole idea is that each vest has it's own vibe and is entirely different than the other vests.. one is red tartan, one is bright yellow, the other one black.. etc. I'm not sure it would go over well here in the u.k. though.. I used to live in Portland Oregon and it has a great underground art scene. i'm living on Glasgow right now and i'm not seeing much of an art scene at all.. where do you live? I'm thnking of moving to London.

    anyway, I have to run. I enjoyed this blog as it was highly informative.

    take it easy,


  10. Hi, nice project!
    I need an interface connecting serial-midi data from an atmega8 to a HID-MIDI device seen by the PC. Do your device receive MIDI Data or it just sends?
    Could you share the code so I could tweak it for my needs?
    Thank you!

  11. Hello,
    Nice project. I'm going to have a crack at it soon.
    But could you update the code link please? Seems to be dead.

    1. Thanks! Must have been a temporary problem with For me the link is still working fine.

  12. Thorsten. Long time no see. Hope all is well! Back again searching the internet for midi related hardware. I have this idea. I want to experiment around with your code in "eclipse," as you mentioned above. I have been into Arduino for a long time so I'm confident I can work through it (first time with eclipse but it looks promising). Anyway, I can't seem to find anyway to load your code into Eclipse. I get close trying to install as a "project," but there is no xml project file and of course, no makefile. Can you help? The thing I like is that you can select the chip in Eclipse so I'm thinking of stepping up to an atmega8 for a couple of extra pins. Hope you'll help!

  13. Hi, I want to make a thing clear which i unable to make out. Is this design is a replacement of USB to MIDI cable? And can I do this thing with Arduino Nano? Thank You

  14. Hello, I am working on building a usb-midi keyboard but am looking to use a atmega328p and some shift register for the inputs. I can do the electronics but I cannot understand the code. Can you help me to adapt the code to use 3 shift registers as inputs?