From eea51782a6a5e3496eb11c236f25755fa90c3405 Mon Sep 17 00:00:00 2001 From: Tilman Date: Wed, 5 Jan 2022 11:14:32 +0100 Subject: [PATCH] Timed key press with ATMega32U4 --- pro_micro_timed-key/pro_micro_timed-key.ino | 31 +++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 pro_micro_timed-key/pro_micro_timed-key.ino diff --git a/pro_micro_timed-key/pro_micro_timed-key.ino b/pro_micro_timed-key/pro_micro_timed-key.ino new file mode 100644 index 0000000..5fa6a39 --- /dev/null +++ b/pro_micro_timed-key/pro_micro_timed-key.ino @@ -0,0 +1,31 @@ +// Presses a key every once in a while on Arduino Leonardo / Pro Micro (ATMega32U4) + +#include "Keyboard.h" + +const int waitTime = 480000; // 8 minutes +const int buttonPin = 2; + +void setup() { + Serial.println("Starting HID"); + pinMode(buttonPin, INPUT_PULLUP); + Keyboard.begin(); +} + +void loop() { + int buttonState = digitalRead(buttonPin); + + if (buttonState == HIGH) { + Serial.println("click"); + + // press right ctrl + Keyboard.press(132); + delay(10); + Keyboard.release(132); + } + else { + Serial.println("LOW"); + } + + // wait 8 minutes + delay(waitTime); +}