Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Emulate Keyboard with an Arduino Micro
- 1 button project connected to pin12, button activates a couple of strings and keypresses on a mac
- A way to complicated way to play music on Google home by [email protected]
- */
- #include <HID.h>
- #include <Keyboard.h>
- const int RedButtonPin = 12;
- String varPassword = ("secret");
- String varSpotlight = ("Terminal");
- String varSay1 = ("say ok Google");
- String varSay2 = ("say maximal volym"); // Swedish voice command
- String varSay3 = ("say spela musik"); // Another swedish voice command (play music)
- long counter = 1;
- void setup() {
- pinMode(RedButtonPin, INPUT_PULLUP);
- Keyboard.begin();
- }
- void loop() {
- int RedButton = digitalRead(RedButtonPin);
- if (RedButton == LOW){
- //Wake up computer from sleep
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(2000);
- //Type in password
- Keyboard.print(varPassword);
- delay(200);
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(3000);
- //Press left cmd and space to activate Spotlight
- Keyboard.press(KEY_LEFT_GUI);
- Keyboard.print(" ");
- Keyboard.releaseAll();
- delay(1300);
- //Enter searchstring into spotlight
- Keyboard.print(varSpotlight);
- delay(1300);
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(1000);
- //let terminal use speech to active google home
- Keyboard.print(varSay1);
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(1500);
- Keyboard.print(varSay2);
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(5000);
- //Activate second batch of voicecommands
- Keyboard.print(varSay1);
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(1300);
- Keyboard.print(varSay3);
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(1000);
- //Exit terminal,
- Keyboard.print("exit");
- Keyboard.press(KEY_RETURN);
- Keyboard.releaseAll();
- delay(1000);
- //Close terminal
- Keyboard.press(KEY_LEFT_GUI);
- Keyboard.print("q");
- Keyboard.releaseAll();
- delay(1000);
- //Logout
- Keyboard.press(KEY_LEFT_GUI);
- Keyboard.press(KEY_LEFT_CTRL);
- Keyboard.print("q");
- Keyboard.releaseAll();
- delay(200);
- }
- }
Add Comment
Please, Sign In to add comment