Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Hid protocol is used for physical interaction devices such as the mouse, keyboard and much more. Many Arduino-compatible development boards support HID (but not all), allowing the microcontroller to behave just like a regular mouse, keyboard or gamepad. These examples are intended for ESP32 boards, such as the ESP32-S3 Thing Plus from Sparkfun.

Warning! You may have a hard time re-programming your Arduino if it’s constantly taking over your mouse or keyboard! You can build in a work around with a little logic and a jumper wire or button. Start your code with something similar to this, which would block the HID behaviour, unless pin 10 is connected to GND.

Code Block
languagecpp

#define HIDdisablePin 10

void setup() {
  pinMode(HIDdisablePin, INPUT_PULLUP);
}

void loop() {
  // Disable the mouse unless HIDdisablePin is connected to ground
  // This would need to be at the start of your loop() function. 
    if(digitalRead(HIDdisablePin) == 1 ) {
         while(1) { /* infinite loop */ }
    }
  // The rest of your code after this line

}