Arduino Due with keyboard.h

Hi, I’d want to buy an Arduino Due, but I’d like to know if it’s compatible with keyboard.h. It’s written that it’s compatible in the docs, but I couldn’t find an example of someone using it, so I’d like to ask here to make sure. I’d also appreciate it if someone knew if I’d just have to follow the same procedure as an Arduino Uno to use the library or if it’s different. Thanks.

I just noticed that on the product page, there is a paragraph mentioning the ability to emulate a keyboard, but it’s “more info“ link leads to a 404…

”The Native USB port is connected to the SAM3X. It allows for serial (CDC) communication over USB. This provides a serial connection to the Serial Monitor or other applications on your computer. It also enables the Due to emulate a USB mouse or keyboard to an attached computer. To use these features, see the Mouse and Keyboard library reference pages.”

You can easily test if it will work on a Due.

Install the board package for the Due, take an example sketch for keyboard.h and compile it for the Due. If it compiles, there will be no issues.

References (instead of the 404 one)

// edit
I've reported it here via https://www.arduino.cc/en/contact-us/

1 Like

Hi,
First of all, for the 404, thanks for reporting it to Arduino.
Secondly, unfortunately, I don't have a Due to test this on since I wanted to check if I could use it as a keyboard or not before ordering one, but I guess I'll risk it, and will come update my post once I get to try it. Let's hope for the best. :crossed_fingers:

I probably should have been more clear. You don't need the board to check if it can compile.

1 Like

Oh, I've misunderstood, sorry. I've compiled some example code from the docs in the IDE, and it compiles without any issue !

edit : Also, would you happen to know if the programming process is the same as for the Uno in terms of uploading the code or if it's different, since it's hard to find ressources about it online @sterretje ?

It's basically the same. There are differences under the hood but if you use the IDE, it is transparent.

If not mistaken the Due uses microUSB; make sure that you use a data cable, not a charge only cable.

Ok.. Do you think I just need to upload the code to the native USB port via the IDE and that’s it then ? I saw that on the Uno you need to put into “Dfu” mode and use some kind of software called FLIP, is that necessary too ? Sorry if these are stupid question, not really an expert in the field..

I'm not familiar with the Due for more than what I described. Which port you use for upload is irrelevant, but I suspect that the HID functionality only works when you connect the board via the native USB to the PC.

An 328P or 2560 based board like the Uno does not have native USB support hence the hack with DFU mode to get the native USB working; and that only works if the Uno has the 16U2 microcontroller (most clones don't).

Why do you opt for a Due? Boards like Leonardo, Micro and Pro Micro also have native USB support.

Ok, i understand now, thank you. I’m opting for a Due since it has significantly more Flash memory (512KB vs 32KB in the other boards with USB Support if I’m not mistaken)which is a must-have for me since I’ll need a lot of Flash for another project that I plan to make after this one.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.