Timed key press with ATMega32U4

This commit is contained in:
2022-01-05 11:14:32 +01:00
parent c97751a4b9
commit eea51782a6
@@ -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);
}