Skip to content

Instantly share code, notes, and snippets.

@danclien
Created January 21, 2021 20:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danclien/6cdebcb4c5f78fce26b8000f545c38f7 to your computer and use it in GitHub Desktop.
Save danclien/6cdebcb4c5f78fce26b8000f545c38f7 to your computer and use it in GitHub Desktop.
// Presses F15 every 30 seconds to keep a computer awake
// Tested on an Arduino Micro
#include <Keyboard.h>
void setup() {
// Initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
// Initialize keyboard library
Keyboard.begin();
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // Turn on the LED
// Push F15 for 200ms
Keyboard.press(KEY_F15);
delay(200);
Keyboard.release(KEY_F15);
digitalWrite(LED_BUILTIN, LOW); // Turn off the LED
delay(30000); // Wait 30 seconds to run again
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment