Raspberry pi pico + Arduino IDE + HID

Hello. I try use my raspberry pi pico as HID-usb to pass some text from it to notepad on PC. I try to use use this code:

#include <Keyboard.h>

void setup() {

  Keyboard.begin();

}

void loop() {

  Keyboard.press('h');
  delay(100);
  Keyboard.releaseAll();

}

but get error:

C:\Arduino\libraries\Keyboard\src/Keyboard.h:25:10: fatal error: HID.h: No such file or directory
Multiple libraries were found for "Keyboard.h"
#include "HID.h"
Used: C:\Arduino\libraries\Keyboard
^~~~~~~
Not used: E:\Arduino\libraries\Keyboard
compilation terminated.
Using library Keyboard at version 1.0.2 in folder: C:\Arduino\libraries\Keyboard
exit status 1
Error compiling for board Raspberry Pi Pico.

Please, help. How to use HID for raspberry pi pico in Arduino IDE. Thanks!

Does the raspberry pi pico support the Keyboard library ?

Where did you get the library from ?

The library was in Arduino IDE

That proves nothing. For instance, the library does not support the Uno but it is possible to #include it in a Uno sketch but it will not work

Read this Keyboard - Arduino Reference

Which Arduino boards platform are you using to add support for the Pico to the Arduino IDE @juffin?

There are two popular ones:

hello. I use this one

OK. That is the official platform, but it's the version with all the boards. That will work just as well, but I recommend using instead the "Arduin Mbed OS RP2040 Boards" option just below it in the menu and uninstalling the "Arduino Mbed OS Boards" platform in Boards Manager. The reason is that the platform with all the boards was getting huge so it was split into individual "families" to make compilations and updates faster.

But that is not relevant to your question.

Sadly, the portability that has been the hallmark of Arduino for many years has not been given priority in the Mbed OS platforms. It is possible to use the HID capabilities, but you can't do that using the standard Arduino libraries. Instead you must learn to use new libraries without the help of proper documentation. You can get some hints about how to start on that effort here:

Cool! Thanks!

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