AVR ATtiny USB Tutorial Part 1

I wanted to build an USB device using AVR microcontrollers since I found out that it was possible. However, both the USBtiny project and the more extensive V-USB library lacked an easy-to-approach tutorial. So I decided to make one.

This first part covers the basics for making USB-powered devices, and serves as introduction for second part, which goes through simple example for using V-USB library to implement USB communication to and from ATtiny2313. Additional parts might be published later if I have the time and there’s interest.

But let’s get started. Here is what you need for this first part:

  • USB cable and pin header
  • Small breadboard and a few jump wires
  • LED and 330 ohm resistor
  • Low voltage drop 3.3V regulator, such as LD1086V33 or LE33CZ

The cable

The first thing we need to do is cut the USB cable so the end that goes into computer remains, strip the other end and solder the four wires into a pin header so it’s easy to plug the cable into a breadboard. USB contains four wires which you should solder in the following order (note: not all cables conform to this so check with a multimeter!):

Pin Color Function
1 Red VCC (+5V)
2 White D-
3 Green D+
4 Black Ground (0V)

Here you see the end result. When stripping the wire, be careful not to damage the wires and make sure the wires will not touch each other so your cable won’t short circuit your computer or USB hub!

Cable with soldered pin header
Continue reading