Smart Screen Sleep / Motion Mouse Wiggler
Smart Screen Sleep controlling the old Surface I use with DAKboard to display a calendar in the kitchen
I've always been torn:
- I find it super annoying when the monitor goes to sleep when you're either reading something, or when I walk by the computer to check on something ("My code's compiling!") and I have to wiggle the mouse to wake it up.
- Leaving the monitor on all the time is super wasteful
The solution? The Motion Mouse Wiggler! Since an Arduino Leonardo or Micro can very easily emulate a USB mouse, the only other hardware that's needed is a PIR motion sensor to tell the Arduino when to wiggle the mouse cursor.
When I first came up with the idea I was afraid that the Arduino wiggling the cursor would cause the cursor to shiver or jump around when I was actually using the computer. So far I've built three of these which are in use on various computers around my house and so far I've found the movement to be undetectable, but your mileage may vary.
Supplies
1x Arduino Micro or Leonardo
5V PIR motion sensor such as a Panasonic NaPiOn AMN41121
2x 2.54mm 12-pin female header pin sockets
microUSB cable
10kΩ resistor
Small section of prototype board
Wire wrap (or any thin wire)
Schematic
Sorry, I know this is pretty lame but it's better than nothing. Some day I'll draw up a proper one, but for the time being:
Schematic of the hardware. Not too much going on; I used pin 2 on the Arduino but you can use whatever is convenient.
Arduino Code
/*
27 May 2020 - Jamie Maloway
SmartScreenSleep - V1.0
Enumerate as a mouse and wiggle the cursor whenever motion is detected.
Because the movement is so small it shouldn't be visible or disruptive.
I've used Panasonic AMN41121 sensors, however the same sketch should work with any similar sensor.
Based on the "ButtonMouseControl" example.
*/
// Use the Mouse library
#include "Mouse.h"
// set pin number for the motion sensor
const int pirSensorInput = 2;
int range = 5; // output range of X or Y movement; affects movement speed
void setup() {
// initialize the motion sensor input:
//pinMode(upButton, INPUT);
pinMode(pirSensorInput, INPUT);
// initialize mouse control:
Mouse.begin();
}
void loop() {
// read the sensor:
//int upState = digitalRead(pirSensorInput); // Where the PIR is connected
int pirState = digitalRead(pirSensorInput); // Where the PIR is connected
if (pirState ==1)
{
wiggleCursor();
}
// short delay to reduce the number of events
delay(100);
}void wiggleCursor()
{
Mouse.move(1,0,0);
delay(500);
Mouse.move(-1,0,0);
}