Last active
October 14, 2016 01:58
-
-
Save jameshih/bd156e8a2fa7ba6423ca381a3bde1d2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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