USB functions with Arduino Leonardo Micro Uno Mega and HID Project

NicoHood edited this page May 5, 2016 · 1 revision
Clone this wiki locally

Extracted from the old Wordpress blog.


This article is all about USB HID functions. It will tell you how to use your Arduino as Mouse (with absolute position as well), Keyboard(with led out report), Consumer(Media) Keys, Power functions(with usb wakeup), Gamepad. It will work on Arduino Leonardo/Micro/Uno/Mega. Yep you heard right. It will work on Uno and Mega too with no disadvantage thanks to HoodLoader2 (one time bootloader flash only)!

I've updated a lot since the release of this post of the HID Project and HoodLoader1 also got an upgrade with HoodLoader2. The HID Project is still up to date, to get the newest update I recommend you to check out the Github pages, since I wont update this post everytime.

See the newer HoodLoader2 for Arduino Uno/Mega.


All you need to do is to install the library from the HID Project properly. See the readme for installation instructions. For the Arduino Uno/Mega you also need to flash the new Hoodloader2.

How to use the library

The library is compatible with all listed Arduinos, even if they all work a bit different. Make sure to install it properly and then you can change from a Micro to an Uno very easy. Keep in mind that you always use the begin() functions. In fact they are not essentially needed for a Micro but if you want to switch to an Uno/Mega you do need them and then you wonder why your code is not working/causes errors.

What next? Well i recommend you to connect a button to pin 2 and gnd and just checkout the examples. They are pretty much self explaining. Also see the official documentation on how to use the Keyboard/Mouse library. Keep in mind that you always have to de/activate USB functions due to a memory limit (see readme). Everything else should be described in the readme, so its always up to date.

A quick example

~~A simple example would be the use of some Consumer (former Media) Keys. You can use them to control your Media player for example. You can find this example (in a more detailed version) in the HID Project. You first need to activate Consumer Control (as described in the readme) in order to use this function.~~ See the example in the repository. This information is outdated.

Some stuff i want to mention:

Please read the readme carefully. It should be very easy if you follow the steps carefully. If something is unclear, ask me in the comments. If you like this and come up with a great project or idea, message me. I will post a list of all cool projects in this blog and the readme. Things i want to do (or already did):
  • Gamecube/Wii to PC adapter
  • Old Gameport Wheel to PC adapter
  • Music Player control with IR remote
  • PC standby/shutdown function controlled by Arduino
  • Keyboard troll program
  • Keyboard logger