shaiss

Untitled

Feb 17th, 2021
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Keyboard.h>
  2.  
  3. /*
  4.  * Mute button for MS Teams
  5.  */
  6. // use this option for OSX:
  7. char ctrlKey = KEY_LEFT_GUI;
  8. // use this option for Windows and Linux:
  9. //char ctrlKey = KEY_LEFT_CTRL;
  10. char shftKey = KEY_LEFT_SHIFT;
  11. //char winKey = KEY_LEFT_GUI;
  12. //char cmdKey = KEY_COMMAND;
  13. //char optKey = KEY_OPT;
  14.  
  15. // constants won't change. They're used here to set pin numbers:
  16. const int BUTTON_PIN = 5;        // the number of the pushbutton pin
  17. const int DEBOUNCE_DELAY = 50;   // the debounce time; increase if the output flickers
  18.  
  19. // Variables will change:
  20. int lastSteadyState = LOW;       // the previous steady state from the input pin
  21. int lastFlickerableState = LOW;  // the previous flickerable state from the input pin
  22. int currentState;                // the current reading from the input pin
  23.  
  24. // the following variables are unsigned longs because the time, measured in
  25. // milliseconds, will quickly become a bigger number than can be stored in an int.
  26. unsigned long lastDebounceTime = 0;  // the last time the output pin was toggled
  27.  
  28. void setup() {
  29.   // initialize the pushbutton pin as an pull-up input
  30.   // the pull-up input pin will be HIGH when the switch is open and LOW when the switch is closed.
  31.   pinMode(BUTTON_PIN, INPUT_PULLUP);
  32.   Keyboard.begin();
  33.   Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  34. }
  35.  
  36. void loop() {
  37.   // read the state of the switch/button:
  38.   currentState = digitalRead(BUTTON_PIN);
  39.  
  40.  
  41.   // check to see if you just pressed the button
  42.   // (i.e. the input went from LOW to HIGH), and you've waited long enough
  43.   // since the last press to ignore any noise:
  44.  
  45.   // If the switch/button changed, due to noise or pressing:
  46.   if (currentState != lastFlickerableState) {
  47.     // reset the debouncing timer
  48.     lastDebounceTime = millis();
  49.     // save the the last flickerable state
  50.     lastFlickerableState = currentState;
  51.   }
  52.  
  53.   if ((millis() - lastDebounceTime) > DEBOUNCE_DELAY) {
  54.     // whatever the reading is at, it's been there for longer than the debounce
  55.     // delay, so take it as the actual current state:
  56.  
  57.     // if the button state has changed:
  58.     if(lastSteadyState == HIGH && currentState == LOW) {
  59.       Serial.println(currentState);
  60.       //Keyboard.press(winKey);
  61.       //Keyboard.press('1');
  62.       //delay(100);
  63.       //Keyboard.releaseAll();
  64.       //delay(100);
  65.       // Keyboard.println("You pressed the button ");
  66.       //mute sequence for chime
  67.       // Keyboard.press(ctrlKey);
  68.       // Keyboard.press(shftKey);
  69.       // Keyboard.press('m');
  70.       //audition
  71.       //Keyboard.press(optKey);
  72.       //Keyboard.press(cmdKey);
  73.  
  74.       //Keyboard.press(shftKey);
  75.       // Keyboard.press(KEY_LEFT_CTRL);
  76.       Keyboard.press(KEY_LEFT_SHIFT);
  77.       Keyboard.press(KEY_LEFT_GUI); //command on mac
  78.       Keyboard.press(KEY_LEFT_ALT); //option on mac
  79.       Keyboard.press('k');
  80.       delay(100);
  81.       Keyboard.releaseAll();
  82.       Keyboard.press(KEY_LEFT_SHIFT);
  83.       Keyboard.press(KEY_DELETE);
  84.       delay(100);
  85.       Keyboard.releaseAll();
  86.     }
  87.     // save the the last steady state
  88.     lastSteadyState = currentState;
  89.   }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment