🛠 Type with your board: HID keyboard over USB-C
Goal
Use the RA4M1 USB peripheral and the core's HID support to enumerate as a USB keyboard: pressing a button types text into whatever app has focus.
Wiring
Momentary button between pin 2 and GND (the internal pull-up does the rest).
Code
#include <Keyboard.h>
const uint8_t BTN = 2;
bool last = HIGH;
void setup {
pinMode(BTN, INPUT_PULLUP);
Keyboard.begin;
}
void loop {
bool b = digitalRead(BTN);
if (last == HIGH && b == LOW) { // falling edge
delay(30); // crude debounce
Keyboard.print("Hello UNO R4!");
}
last = b;
}
Open Notepad, press the button: the board types. You can also send Keyboard.press/release combos for shortcuts (Ctrl+..., arrows, F-keys).
Expected result
One phrase per press, no driver needed - the PC sees a standard HID keyboard.
Common mistakes
- Watching Serial while the sketch floods a text editor: the Serial monitor is just another listener.
- Crude 30 ms debounce double-firing on bouncy buttons.
- Typing into a terminal you depend on: test in a scratch document first.
- Expecting wireless: the Minima has no radio, HID is over the USB-C cable only.
Autres tutoriels pour cette carte
Exemples de code pour cette carte
clignotante.inoArduinobouton-poussoir.inoArduinodac-analogique.inoArduinoentree-analogique.inoArduinopwm-respiration.inoArduinoservo-balayage.inoArduino