Notes

This library is very specific to Pro Trinket and its USB connector.

If you wish to use the ATtiny85-based Trinket, see the Trinket Keyboard tutorial. The library for one cannot be used on the other.

Some good news is the library calls for the Pro Trinket Keyboard are the same as the Trinket Keyboard library.  If you develop a sketch for either Trinket or Pro Trinket, just link to the appropriate library to make it work (barring changes in hardware pin connections).  Pro Trinket has more memory and pins to use,.  If you run out of resources on your Trinket project, consider swapping hardware for Pro Trinket!

Note the software can only emulate a USB 1.1 device.  USB 1.1 cannot perform functions defined for USB 2 or USB 3 devices like virtual serial ports or mass storage devices.  

If you wish to use a different development board than the Pro Trinket, it is suggested you consider the Arduino Micro, Leonardo, or Due.  The Arduino IDE has built-in functions for keyboard and mice emulation.  For more information, see the official Arduino website for details.

How is the software implemented?

Trinket and Pro Trinket are based on V-USB. V-USB is a bit-bang implementation of USB. The code outputs 1s and 0s to the USB signal pins with precise timing.

V-USB is designed for AVR microcontrollers without native USB capabilities. USB signals have tight timing specifications that must be met, which is why the timing critical portions of V-USB are written in assembly code. Assembly instructions have predictable execution times and thus it is easier to calculate timing.

The ability to make a USB device without dedicated USB hardware is what makes V-USB so cool! Most of the microcontrollers on the market with native USB are bigger and cost more, but V-USB can turn two data lines on an AVR chip into an USB device!

To learn more about V-USB, check out the example projects on the V-USB website.

Pro Trinket can do almost any of those projects as the Pro's ATmega 328P most often has enough pins and enough flash memory to use.

This guide was first published on Jan 03, 2015. It was last updated on Jan 03, 2015. This page (Notes) was last updated on Aug 18, 2019.