Created
April 26, 2022 23:01
-
-
Save stringsn88keys/735e5d8910d83097d1c3c73060a01a0c to your computer and use it in GitHub Desktop.
Arduino mouse mover to keep PC awake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Mouse.h> | |
void blinkIfYoureRebooted() { | |
// 200, 400, 600, 800, 1000ms blinks | |
for(int i=1; i<=5; i++) { | |
digitalWrite(LED_BUILTIN, HIGH); | |
delay(200 * i); | |
digitalWrite(LED_BUILTIN, LOW); | |
delay(200 * i); | |
} | |
} | |
void setup() { | |
// this runs once | |
pinMode(LED_BUILTIN, OUTPUT); | |
blinkIfYoureRebooted(); | |
// Mouse movement works with any ATmega32U4 device | |
Mouse.begin(); | |
} | |
void loop() { | |
// 10090 is a completely arbitrary number but | |
// it seems to move a barely perceptible amount | |
// a few times per second at most. | |
if(random(0,10090)==0) { | |
Mouse.move(random(0,5)-2, random(0,5)-2,0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment