This is another short example of a demo application that makes use of the V-USB library together with an Arduino. I show, how an USB keyboard functionality can be implemented.

The motivation: The V-USB library provides a quite simple possibility to realize USB devices with arbitrary USB descriptors. This is useful, for example, if the device that you want to connect to can only handle certain types of USB devices. The V-USB library allows you to implement exactly the device descriptor that can be understood by the other device.

This exemplary project is a summary from various sources. I do not want to repeat all the detailed explanations from these sources in the following, but rather show how to build a working example. For a deeper understanding I give a list of usefull links that should help for an understanding at the end of this post.

This example makes use of the Arduino 1.0 IDE and the fifth alpha release of the V-USB library. To setup the USB keyboard, we need the following parts:

1 Arduino board. I have a Duemilanove, but I assume that any other board (even any other ATMEGA controller?) would also do.



For the USB interface: 1x USB “B” female socket 1x 2K2 (i.e., “2.2 kilo Ohms”) resistor, 1/4W 2x 68R (i.e., “68 Ohms”) resistor, 1/4W 2x 3.6V Zener diode, 1/4W



For the button:

1x switch/push button etc.

1x 10K resistor

For the assembling, we need a breadboard and some jumper wires. I used these schematic for setting up the button circuit:

To ease the connection to the USB socket, I prepared the following image, which indicates the pin out of a USB-B female socket:

For connecting the USB socket, I used this schematic:

To give you an idea about how everything could look after assembling, here is my circuit:

If you have not installed the V-USB library already, download the library and unzip it into the “libraries” directory of your Arduino folder. No modifications of the library files are needed in order to make this example work. The following program initializes the USB keyboard and iteratively checks, if the button is pressed. If a press is recognized, the letter “a” is send via the USB keyboard interface. This is the source code, that you simply have to compile and upload with the Arduino IDE:

[gist id=3051606]

More details about this small USB keyboard project can be found in the book “Practical Arduino“. If you feel that you lack some more basic understanding of the Arduino and microelectronics, the short book “Getting started with Arduino” provides a really nice introduction to these topics. Detailed tutorials about the V-USB library can also be found in the blog of Joonas Pihlajamaa.