1

I am trying to use keyboard on my Arduino nano, but i get this error:

'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

As per the answer in Keyboard.h not found, I tried change the board to Arduino Leonardo, even though the script gets compiled it doesn't get uploaded (keeps on saying uploading for a long time).

This is the code I use:

#include <Keyboard.h> 
void setup() {
  Keyboard.begin();
}
void loop() {
}
2
  • 4
    If you also change the board itself, it'll work. The Uno has different MCU and it doesn't have physical USB interface in it.
    – KIIV
    Nov 8, 2021 at 7:36
  • 4
    As said above you cannot use the Keyboard library on the Nano. It just doesn't have the necessary hardware
    – chrisl
    Nov 8, 2021 at 8:00

1 Answer 1

1

To convert the comments into an answer:

You cannot (!) use the Keyboard library on the Arduino Uno/Nano/Mini. It needs a native USB interface to configure it as a HID device, but the Uno/Nano/Mini all use the Atmega328p, which doesn't have a native USB interface. These Arduinos use an additional chip on the board which acts as USB-UART-bridge.

You can compile the code for the Leonardo, because it has a native USB interface. But you cannot (!) upload code, which is compiled for the Leonardo, to an Uno/Nano/Mini. Its a completely different chip.

What to do now: Get an Arduino board which has a native USB interface, for example the Leonardo or the Micro.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.