Description
Thanks nshadov for your code, here is my modified version.
Every 30 minutes of inactivity my screen locks. I am at work for 9 hours.
Added start button to wake computer and start 9 hour loop, this way PC can lock when I am not there.
Button push moves mouse 10 pix to the left, this is enough to wake PC (and verifies program is started) and starts 9 hour timer.
Every 20 minutes, I move mouse 1 pix to the left, this small move you will never bother you during use.
`/*
- NAME: ScreenSaver Mouse Jiggler
- DATE: 7-21-2020
- DESC: Set delay in milliseconds till next move, set loop number, press button connected to pin#2 to start. Needs to have arduino mpu 32U4 to work (Leonardo, Pro Micro, Arduino Micro it what I had board set to)
- AUTHOR: Freedom
- VERSION: 1.0
*/
#include <Mouse.h>
//# This is run once, during device initialization
void setup()
{
// Define pin #2 as input and activate the internal pull-up resistor
pinMode(2, INPUT_PULLUP); //connect push button from pin#2 to ground, for waking up computer and starting the jiggle.
Mouse.begin();
}
//# Main loop - move mouse back and forth every X seconds (set in delay)
void loop()
{
int buttonValue = digitalRead(2);
if (buttonValue == 0)
{
int count = 27; // set loop count, 27 is 9 hours with 20 min delay
delay(1000);
Mouse.move(-10,0,0); //move mouse x,y, this is large mouse move to wake computer
while(count > 0 ) //keep looping till if count > 0
{
Mouse.move(-1,0,0); //move mouse x,y
//delay(100);
//Mouse.move(-2,0,0);
//delay(100);
//123
// Mouse.move(1,0,0);
delay(1200000); // delay in milliseconds till next move 1,200,000 is 20 minutes
count = count -1; //subtract 1 from count after waiting 20min
}
}
}`