souris-cercle.ino
The Mouse library enumerates a relative HID mouse: Mouse.move shifts the pointer pixel by pixel. Open a drawing app and watch a circle trace itself — the classic 32U4 demo.
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
USB cable to the computer.
How it works
Relative coordinates are computed on a 50 px circle and sent every 10 ms; the pointer follows the path. 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
Add a potentiometer on A0 to steer the radius, or a button to click (Mouse.click).
souris-cercle.ino
// L'Arduino devient une souris HID : deplace le curseur en cercle.
#include <Mouse.h>
void setup() {
Mouse.begin();
delay(2000);
Mouse.move(100, 0); // part du centre vers la droite
}
void loop() {
const int RAYON = 50;
for (int degre = 0; degre < 360; degre += 5) {
float a = degre * 3.14159 / 180.0;
float b = (degre + 5) * 3.14159 / 180.0;
int dx = (int)(RAYON * (cos(b) - cos(a)));
int dy = (int)(RAYON * (sin(b) - sin(a)));
Mouse.move(dx, dy);
delay(10);
}
delay(1000);
}