OS: Mac Arduino: 1.8.13 Keyboard Library: 1.0.2
I have a generic ESP8266 board, and I have the following code
void setup() {
// put your setup code here, to run once:
pinMode(LED_BUILTIN, OUTPUT);
Keyboard.begin();
}
void loop() {}
However I get the following ouput:
In file included from /Users/quba/Sandbox/sketch_feb07a/sketch_feb07a.ino:1:0:
/Applications/Arduino.app/Contents/Java/libraries/Keyboard/src/Keyboard.h:25:17: fatal error: HID.h: No such file or directory
#include "HID.h"
^
compilation terminated.
exit status 1
Error compiling for board Generic ESP8266 Module.
Could not find boards.txt in /Users/quba/Library/Arduino15/packages/arduino/hardware/megaavr/1.8.7. Is it pre-1.5?
1 Answer 1
The Keyboard library is for Arduino ATMega32U4 based Arduinos (and other similar ones with USB) only. The ESP8266 does not have USB, so how can it possibly use the Keyboard library?
-
I have added a picture so you can see the TX and RX pins, as well as the USBQuintin B– Quintin B2021年02月08日 08:02:11 +00:00Commented Feb 8, 2021 at 8:02
-
2The keyboard library is meant for devices that can talk DIRECTLY to the USB bus, like the AVR ATMega32u4. The ESP8266 on the NodeMCU you show in your picture does not have that capability but it has a separate Serial-to-USB chip that's able to talk to a PC via USB. Even then, it can only act as a peripheral to a PC and not as a USB "Master" that's able to control its own USB peripherals (like a keyboard).StarCat– StarCat2021年02月08日 09:34:32 +00:00Commented Feb 8, 2021 at 9:34