Skip to content

Instantly share code, notes, and snippets.

@glennlopez
Created September 25, 2021 22:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennlopez/e45f7eee9ee59f4be06360ce0b5f5b10 to your computer and use it in GitHub Desktop.
Save glennlopez/e45f7eee9ee59f4be06360ce0b5f5b10 to your computer and use it in GitHub Desktop.
PIR Assisted Mouse Ider
#include <Mouse.h>
int LED = 13; // the pin that the LED is atteched to
int PIR = 3; // the pin that the sensor is atteched to
void setup() {
pinMode(LED, OUTPUT); // initalize LED as an output
pinMode(PIR, INPUT); // initialize sensor as an input
Serial.begin(9600); // initialize serial
}
void loop(){
if (digitalRead(PIR) == HIGH) { // check if the sensor is HIGH
digitalWrite(LED, HIGH);
int i;
for (i = 0; i < 2; i++)
{
Mouse.move(1,0);
delay(25);
}
for (i=0; i<2; i++)
{
Mouse.move(-1, 0);
delay(25);
}
Serial.println("Motion detected!");
delay(100);
}
else {
digitalWrite(LED, LOW);
Serial.println("Motion stopped!");
delay(100);
}
}
@glennlopez
Copy link
Author

glennlopez commented Sep 25, 2021

Moves the mouse by 1 pixel and back if there is motion in the room. Prevents computer from logging you off due to afk inactivity if you are in the same room. Resumes the same default security protocol if no motion is detected.

@micheal-death
Copy link

Does this still work?

@micheal-death
Copy link

@glennlopez Yah, I mean can this trick bypass the automatic shutdown of the Shadow PC?

@micheal-death
Copy link

@glennlopez Thanks for the reply. So, running this script on the Shadow PC won't work, it has to be run on the host computer, right?

@micheal-death
Copy link

@glennlopez Oh, I see...I will dig into these, thanks again.

@micheal-death
Copy link

@glennlopez Oh, you are so kind, bro. I bought an Arduino Micro and tried it as you said. It worked like a charm, the Shadow PC won't shut down automatically anymore. Thanks again for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment