clavier_media.ino
The 32U4 is a full USB device: a header button becomes a media key sent to... the LattePanda host itself. The complete circuit button → HID → system, no wires, no drivers.
Hardware required
A LattePanda Alpha (x86 Intel m3-7Y30, Windows 10 or Linux) with its ATmega32U4 co-processor, Arduino Leonardo compatible, on the 50-pin headers. 1 push button (D2 to GND).
Wiring
Button between D2 and GND. The MCU links to the host over the internal serial bus — the USB HID leaves the 32U4 toward the PC via the internal controller.
How it works
Keyboard.write sends a standard HID report; the host kernel treats it as a real keyboard. Holding paces repeats at 1 Hz. The ATmega32U4 is a genuine Leonardo: flash it as « Arduino Leonardo » in the IDE through its internal COM port. Host-side, DFRobot's lattepanda Python library talks to it over serial.
Going further
A shortcut pad for the studio (mute mic, play), or a keyboard+mouse combo for presentations.
clavier_media.ino
// Cote MCU (carte « Arduino Leonardo ») : le 32U4 est le clavier.
// Bouton D2 = touche volume +/- ; le PC (l'hote !) recoit les medias.
#include <Keyboard.h>
const int BOUTON = 2;
void setup() {
pinMode(BOUTON, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
if (digitalRead(BOUTON) == LOW) {
Keyboard.write(KEY_MEDIA_VOLUME_UP);
delay(150); // repetition volontairement lente
while (digitalRead(BOUTON) == LOW) {
if (millis() % 1000 < 20) Keyboard.write(KEY_MEDIA_VOLUME_UP);
delay(5);
}
}
// Raccourcis utiles : KEY_MEDIA_PLAY_PAUSE, KEY_LEFT_GUI...
}