Skip to content

Instantly share code, notes, and snippets.

@sowbug
Created July 2, 2023 21:16
Show Gist options
  • Save sowbug/27e6dc598d92328952070e08eac5287f to your computer and use it in GitHub Desktop.
Save sowbug/27e6dc598d92328952070e08eac5287f to your computer and use it in GitHub Desktop.
USB mouse wiggler for Arduinos that can emulate USB devices
#include "Mouse.h"
void setup() {
Mouse.begin();
// Give it a sec to initialise, or we miss the first jiggle when it's plugged in
delay(5000);
}
int shift = 5;
int instdelay = 50;
int jiggledelay = 30000;
void loop() {
// Clockwise circle
Mouse.move(shift, -shift, 0);
delay(instdelay);
Mouse.move(shift, shift, 0);
delay(instdelay);
Mouse.move(-shift, shift, 0);
delay(instdelay);
Mouse.move(-shift, -shift, 0);
delay(instdelay);
// Counter-clockwise circle
Mouse.move(-shift, -shift, 0);
delay(instdelay);
Mouse.move(-shift, shift, 0);
delay(instdelay);
Mouse.move(shift, shift, 0);
delay(instdelay);
Mouse.move(shift, -shift, 0);
delay(instdelay);
// And thus we have a figure 8, back at the starting place.
delay(jiggledelay);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment