Using Vusb on an Attiny 85 with the Arduino IDE

Hey there, I am working on a little project where I am programming some Attiny 85 with the Arduino IDE. It works very well :) Now I do need something with a USB connection to talk to a pc. I found out about VUSB (great project!) and that it works with Attiny 85 if you flash some files onto them directly. There is also this arduino clone . But when I try to use that first example I get several errors

In file included from UsbKeyboardDemo1.pde:1:
/UsbKeyboard.h: In constructor 'UsbKeyboardDevice::UsbKeyboardDevice()':
UsbKeyboard.h:131: error: 'PORTD' was not declared in this scope
UsbKeyboard.h:132: error: 'DDRD' was not declared in this scope
UsbKeyboardDemo1.pde: In function 'void setup()':
UsbKeyboardDemo1:15: error: 'TIMSK0' was not declared in this scope

The first two errors seems to be Ports that the Attiny doesn't have (only PORTB?!). There is a usbconfig.h with USB_CFG_IOPORTNAME. Would it be enough to change this from D to B ? The last error is a timer where the attiny does only have one. If I change this to TIMSK and the first one to B I get another error:

#error "USB_CFG_CLOCK_KHZ is not one of the supported non-crc-rates!"

There is also a #define USB_CFG_CLOCK_KHZ (F_CPU/1000) line in the usbconfig... how do I change that to the right level?

I hope you guys can help me.

I found this, where someone did nearly what I wanna have. I downloaded it and after I changed some variables to const I could use the makefile (only with linux...). Then I could use avrdude to burn the hex file onto the attiny 85. That worked too ;) Nothing happens when I connect it to a pc though...

PS I cant seem to get this thing to talk to my pc ;) Sometimes I get an unknown Device sometimes nothing at all... strange.

I'm pretty sure DigiSpark uses VUSB and is certainly ATTiny85 based. I've not looked into it too deeply but you may find a hint you need in the Micronucleus bootloader. Be sure to check and adhere to their license terms if you do however.

Cheers ! Geoff

This should help...


Hey, thanks for the answers.
I am reading everything I can find about this and was able to compile/make the hex file from the link. I also set the fuses to lfuse:w:0xe1:m -U hfuse:w:0xdd:m like mentioned in the post and flashed the attiny85 (using an arduino as ISP and avrdude).
The problem is: it still doesn’t work. When I plug the usb in (for windows) I get an Unknown Device. When using linux I get errors like:

new full-speed USB device numer x using uhci_hdc
device not accepting adress x, error -71

where x are different numbers each time.
So i guess enumerate fails…?!

I checked my setup again and again and I cant find any errors. Any ideas where they might be or what I can do?

PS Here is a picture of my setup. Perhaps there is an error somewhere afterall…
If its too small to see: The green wire from the usb is the yellow wire and the white from USB is the white wire on the breadboard.

Do not fall on your Samurai, yet!

I have done more V-USB projects than I can count and I have showcased some of the intefaces:

I did not look at your PIX, but almost always, the problems are

  • Noise from wiring length
  • Wrong Zener diodes

If you are sure that D+ and D- are properly identified and wired correctly, the the Zeners are the most likely suspect. The zeners are very critical and in the link above I give the part number of the ones that I have used successfully.

On Windows, V-USB seems to work best on USB 1.1 ports and USB 2.0 (older ports) but is really problematic on USB 3.x ports. If you PC has a USB 2.x port, use this one instead of the high speed 3.x port.

Honestly, with the advance in technology in PC hardware, I would not doubt that V-USB ceases to be viable on the newest hardware in a year or so. Perhaps someone will write a PC/Windows driver that can be utilized instead of the Windows HID driver, but so far that has not happened and the generic driver is becoming more particular to V-USB.

If you like the concept of V-USB and wish to be more in control, check out the Leonardo or Leo'ish clone. The USB interface is far more stable.

Good luck,


Great, it works now. Thanks for your support! If someone has the same problems check: - do you use the right z diodes? I did get new ones with 1/2W, now it works - Are D+ and D- wired correctly? Had to switch them up.