Go Down

Topic: library error ['Keyboard' not found] when [#include <Keyboard.h>] is included (Read 116 times) previous topic - next topic

DIY-Systems

With a brand new install of Arduino IDE with either 1.8.10 or 1.9 beta, on either windows or linux I have the error:

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

This happens even with the example sketch via "File>Examples>USB>Keyboard>KeyboardMessage" and it does contain #include <Keyboard.h>

Am I missing something obvious? is this a bug?



One Example of "full" Error Message:

Arduino: 1.9.0-beta (Linux), Board: "Arduino/Genuino Uno"
~
/home/ubuntu/Downloads/arduino-PR-beta1.9-BUILD-116/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino: In function 'void setup()':
KeyboardMessage:33:3: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
   Keyboard.begin();
   ^~~~~~~~
/home/ubuntu/Downloads/arduino-PR-beta1.9-BUILD-116/examples/09.USB/Keyboard/KeyboardMessage/KeyboardMessage.ino: In function 'void loop()':
KeyboardMessage:46:5: error: 'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?
     Keyboard.print("You pressed the button ");
     ^~~~~~~~
Multiple libraries were found for "Keyboard.h"
 Used: /home/ubuntu/Downloads/arduino-PR-beta1.9-BUILD-116/libraries/Keyboard
Multiple libraries were found for "HID.h"
 Used: /home/ubuntu/Downloads/arduino-PR-beta1.9-BUILD-116/hardware/arduino/avr/libraries/HID
Using library Keyboard at version 1.0.2 in folder: /home/ubuntu/Downloads/arduino-PR-beta1.9-BUILD-116/libraries/Keyboard
Using library HID at version 1.0 in folder: /home/ubuntu/Downloads/arduino-PR-beta1.9-BUILD-116/hardware/arduino/avr/libraries/HID
exit status 1
'Keyboard' not found. Does your sketch include the line '#include <Keyboard.h>'?

pert

The Keyboard and Mouse libraries are not compatible with the Uno board you are compiling for. If you have an Uno board, you will not be able to use these libraries. You would need to get a board with native USB functionality (e.g., Leonardo, Micro, MKR, Nano 33 IoT, Zero, Due) to use these libraries. If you do have a board with native USB, then you need to select the correct board from the IDE's Tools > Board menu.

DIY-Systems

The reference states "These core libraries allow the 32u4 and SAMD based boards (Leonardo, Esplora, Zero, Due and MKR Family) to appear as a native Mouse and/or Keyboard to a connected computer."

I had it set to the Nano, and thats apparently not compatible regardless if some people said it was

pert

The reference states "These core libraries allow the 32u4 and SAMD based boards (Leonardo, Esplora, Zero, Due and MKR Family) to appear as a native Mouse and/or Keyboard to a connected computer."
Yeah, that was the "obvious" thing you missed, but I didn't want to say it.

I had it set to the Nano
No. You had it set to Uno:
Arduino: 1.9.0-beta (Linux), Board: "Arduino/Genuino Uno"
thats apparently not compatible regardless if some people said it was
Where did you see people saying it was compatible? The original Nano is not compatible. The Nano Every is not compatible. The Nano 33 BLE boards are not compatible, though support will likely be added in the future. The Nano 33 IoT is compatible.

Go Up