Learning To Use The V-USB (AVR USB Firmware) Library

The V-USB library is a pretty handy piece of code that lets you add USB connectivity to ATtiny microcontrollers (it was previously named tinyUSB). But if you’ve ever looked into adding the library to your own projects you may have been stymied by the complexity of the code. There are many examples, but there’s a lack of a concise quick-start for the uninitiated. [Joonas Pihlajamaa] has been working to correct that shortfall with his four-part V-USB tutorial series. It’s not for the absolute newbie; you should already be comfortable working with AVR chips but that’s the only real prerequisite we can see.

He starts the series with a look into the hardware considerations. USB provides a 5V power rail but the data lines expect 3.3V logic so this must be accounted for. With the test rig built on a breadboard he moves on to pick apart the code, covering various user-defined variables that you’ll need to set based on your project’s needs. We’re going to keep this on the back burner and hopefully the Troll Sniffing Rat will get a makeover (although we must say comments have been a lot nicer as of late… keep it up!).

We’ve embedded links to all four tutorial parts after the break.

17 thoughts on “Learning To Use The V-USB (AVR USB Firmware) Library

    1. did i need to program it first with usbasp programmer !!!
      because i am trying to connect it at first time with cable usb
      it reads the atmega as unknown device and the usbasp driver is installed already

  1. That’s really great! I have already tried to start with V-USB, but it really looked too complicated for kick-start without proper tutorial. Now I hope things will get a lot better and I will finally be able to start using USB in my projects.

    Thank you!

  2. Perfect timing, yet again. :) I’ve been having an interesting time getting an ATmega32U4’s USB to work as I want it, and this looks like a great help to better understanding how it works, particularly the fourth part of the tutorial. Thanks, HaD!

    And look, no tArduino stuff! :D WOOHOO!!!!

  3. Nice tutorial…have loved V-USB since back when it was AVR-USB and I used it in the Capslocker project. Just this week I set up V-USB on an ATtiny45 as a custom class device, to act as an I2C gateway to a ChronoDot (trying to re-create the Maxim DS3231 live demo). The V-USB documentation wiki is also pretty useful.

    1. The problem with all the V-USB examples is that most of them require libusb-win32 which I found to be too complicated for the common user.
      I would like to see a dumb’ed down Arduino lib like Rancidbacon’s http://code.google.com/p/vusb-for-arduino/ but with HID comms examples (not keyboard/mouse) that are easy to get working for Win7x64 users without libusb or custom/hacked drivers.

      But I think most of the Arduino crowd are just moving to atmega32u4 style chips that support USB CDC (serial) natively.

  4. Thanks for every reader who visited the tutorial, I was really happy to see such interest and hope many found the articles useful! As a thanks, I added a post on turning the project to a USB HID mouse:

    http://codeandlife.com/2012/02/11/v-usb-tutorial-continued-hid-mouse/

    Those are some loooong wire runs on those breadboards Pilgrim

    If you were referring to me then yes, placing ATtiny, regulator/USB circuit and ISP programming header on different corners of the breadboard for clarity made for some long wire runs. Don’t try this at home! ;)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.