Skip to content

Instantly share code, notes, and snippets.

@jameshih
Last active October 14, 2016 01:58
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 jameshih/bd156e8a2fa7ba6423ca381a3bde1d2d to your computer and use it in GitHub Desktop.
Save jameshih/bd156e8a2fa7ba6423ca381a3bde1d2d to your computer and use it in GitHub Desktop.
/*
Screen Timer v1
Author: James Shih
references
https://www.arduino.cc/en/Reference/KeyboardModifiers
https://www.arduino.cc/en/Reference/KeyboardPress
*/
#include <Keyboard.h>
#include <HID.h>
char cmdKey = KEY_LEFT_GUI;
char shfKey = KEY_LEFT_SHIFT;
char rtnKey = KEY_RETURN;
int caseState = 0;
void setup() {
Keyboard.begin();
}
void loop() {
switch (caseState) {
case 0:
delay(1000);
caseState++;
break;
case 1:
//Logout Mac
Keyboard.press(cmdKey);
Keyboard.press(shfKey);
Keyboard.press('q');
//delay(100);
//Keyboard.press(rtnKey);
delay(100);
Keyboard.releaseAll();
delay(100);
caseState++;
break;
case 2:
Serial.println('END');
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment