Mouse Wiggler
The computer thinks it’s a usb mouse. When activated, it jiggles the mouse cursor a random tiny distance and direction, every 50-60 seconds.
The breathing LED means it’s active. This makes sure a work computer won’t go to sleep when you want it awake, without changing any settings. Just a slap of the big red button and she’ll sleep like mother IT department intended. All you need is a @sparkfun #ProMicro and the #Arduino software to program it. You don’t even need to add the button, it’s active by default. Code below for Pro Micro or Leonardo.
// woz.lol mouse wiggler
// acts like a mouse, jiggles the cursor about every min
#include <Mouse.h>
#define secs 60
int x;
int y;
#define swich 20
bool pwer;
int secsx;
void setup() {
Mouse.begin();
pinMode(17, OUTPUT);
pinMode(0, INPUT);
pinMode(18, OUTPUT);
digitalWrite(18, LOW);
pinMode(swich, INPUT_PULLUP);
randomSeed(analogRead(0));
delay(1000);
Mouse.move(2, 2, 0);
}
void loop() {
onn();
}
void onn() {
while (1) {
if (random(2)) {
x = random(4) + 2;
} else {
x = -2 - random(4);
}
y = random(5) - 2;
Mouse.move(x, y, 0);
secsx = secs / 6 + random(5);
for (int w = 0; w < secsx; w++) {
for (int a = 0; a <= 100; a++)
{
chkswitch();
digitalWrite(17, LOW);
delay(a / 5);
digitalWrite(17, HIGH);
delay(20 - a / 5);
}
digitalWrite(17, LOW);
delay(150);
for (int a = 100; a >= 0; a--)
{
chkswitch();
digitalWrite(17, HIGH);
delay(20 - a / 5);
digitalWrite(17, LOW);
delay(a / 5);
}
}
delay(250);
}
}
void offf() {
digitalWrite(17, HIGH);
while (1) {
chkswitch();
}
}
void chkswitch() {
if (!digitalRead(swich)) {
delay(300);
if (pwer) {
pwer = LOW;
onn();
} else {
pwer = HIGH;
offf();
}
}
}