Uno + USB Shield = Leonardo?

I want access to the keypress library, but the documentation says this only works with Leonardo or Due, however some other people say that USB shield with Uno or Mega will be sufficient. Can it be done? Is this just an oversight in the documentation, or are the other people just guessing that it's possible?

You need to look up what USB "hosts" and "devices" are!

Thanks. It's a good article and I appreciate the education, but doesn't really talk about these specific devices and I'm not familiar enough with USB shields to understand how to take the info from the article and apply it to Arduino with shield.

I guess another way to put the question is: does the USB shield allow the Uno/Mega to operate as a HID and can it use the keypress library functions (that is to say, can I do LCTRL + RSHIFT + F3)? Output to ordinary serial is very limiting. I need the OS to think of this device as a USB keyboard or if not then at least a set of joystick buttons (but prefer keyboard for simplicity).

I do have Leonardo boards, but not enough of them for what I want to achieve. Now I am in this situation of having to choose whether to buy more Leonardos (expensive) or USB shields for the Unos (mega even better, but I haven't seen many shields that are made for mega). That second option seems attractive but I don't want to waste money on something that's not going to work.

The answer is: No.

The shield is a USB host. It allows you to connect USB devices to your Arduino board. But you are wanting to use your Arduino as a USB device, with the computer as the host.

osita-th:
Now I am in this situation of having to choose whether to buy more Leonardos (expensive) or USB shields

Have you priced the USB host shields? I'm certain the combination of a shield and Uno or Mega is much more than a Leonardo or Micro.


Now if you're really set on this course and you have an official Uno or Mega, or a faithful clone that uses the ATmega16U2 USB to serial chip rather than the cheap CH340, it is possible to program the ATmega16U2 to provide this HID capability. You can find more information about that here:

However, you should be aware that this is a very advanced procedure and there is the possibility you could end up "bricking" your Uno/Mega if something goes wrong. Getting a standard native USB Arduino board is the easy way.

Thanks for the clarification. That really helps a lot and is easy for me to understand. Plus this advice has saved me from a costly mistake!

Yes I do know that the cost of Uno / Mega + Shield is expensive more than Leonardo, but I already have those Unos and Megas just sitting around collecting dust. But only small number of Leonardos. That was why, plus other people had suggested that the shield will get the job done, but as you explained so well, it's not really the same technology at all.

You're welcome. I'm glad if I was able to be of assistance.

Probably the closest thing to a USB device shield for an Uno or Mega, would be to just connect a native USB board like the Micro or Pro Micro. But then you could just use the Micro or Pro Micro alone. Maybe it would make sense for an application where the native USB Arduino board was not able to handle its USB device duties at the same time as the other work reuired of it. A simple example would be if you needed more I/O pins, though of course there are options for expanding the number of pins on an Arduino board.

So two things here:

Many ("clone") modules advertised as "UNO"s are not UNOs at all but blatant frauds, a variant of the earlier Duemilanove as they are missing the 16U2 USB interface that makes the UNO a UNO. Mostly this does not matter if you do not need the HID functionality, you just use whatever USB interface is provided as long as you have the drivers for it (or use Linux which always has the drivers :grinning: ).

The only reason to use the UNO form factor - such as the Leonardo - is if you have a shield with the functionality you need. Otherwise the smaller form factor of the Nano or Pro Micro is more conveniently compatible with a solderless breadboard, "terminal adapter" or protoboard/ stripboard and cheaper (particularly for clones with the same functionality).