saisie-serie-vers-clavier.ino
This bridge showcases the 32U4 double USB personality: serial port for the computer, keyboard for… the same computer. Send text to the serial monitor and it appears in any input field.
Hardware required
An Arduino Micro (ATmega32U4, 16 MHz, 5 V) in a breadboard-friendly format with a micro-USB connector and native USB (keyboard/mouse). None.
Wiring
A single USB cable (the 32U4 enumerates serial + keyboard on the same cable).
How it works
Each received byte becomes a HID keystroke; newline becomes Enter. The short delay keeps the USB buffer from overflowing. In the Arduino IDE, select « Arduino Micro » and the port, then Upload. On Windows a .inf driver may be needed for the COM port. Since the 32U4 is the USB itself, a bad sketch can lock out reflashing (double reset).
Going further
Wire a serial barcode reader to Serial1 (RX1/TX1) for a scan → auto-type pipeline.
saisie-serie-vers-clavier.ino
// Pont serie -> clavier : ce qui arrive sur Serial est "tape".
#include <Keyboard.h>
void setup() {
Serial.begin(9600);
Keyboard.begin();
delay(2000);
Serial.println(F("Mesurez-vous : je retape tout ce qui arrive."));
}
void loop() {
while (Serial.available()) {
char c = Serial.read();
if (c == '\n') { Keyboard.write(KEY_RETURN); }
else if (c == '\r') { /* ignore */ }
else { Keyboard.write(c); }
delay(2); // laisse le tampon HID respirer
}
}