Mute button for MS Teams
Pro Micro as HID keyboard
In this new virtual reality of 2020 where we spend most of the day in Teams-meetings, it would be nice to have a dedicated button on the desk to mute/unmute the microphone in the Microsoft Teams application.
The Pro Micro can emulate a HID-class USB device (Human Interface Device). We are using it to send keyboard shortcuts to the Windows 10 pc. Place the Teams application on the left-most spot on the Windows Taskbar. Press the button. The Pro Micro sends first "WinKey+1" to select Teams. Then it sends "Ctrl+Shift+M" to togle mute.
UPDATE: This works great to unmute the microphone. Unfortunately, most of the times it doesn't work to mute. I'm using it when I want to unmute, and use the mouse as before to mute again. The LED was unneccessary as well. I removed it from the final version.
Anyway, it's a fun project. Use the largest button you can get your hands on....
// *******************************************************************
//
// MUTE/UNMUTE MICROPHONE IN TEAMS
//
// (Place TEAMS in the left-most spot on the Windows TASKBAR)
//
// VERSION 1.0 / 28.10.2020
//
// *************************LIBRARIES*********************************
#include <Arduino.h> // This line is not needed in the Arduino IDE
// https://github.com/arduino-libraries/Keyboard
// https://www.arduino.cc/reference/en/language/functions/usb/keyboard/
#include <Keyboard.h>
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
// **************************HARDWARE*********************************
#define BUTTON_PIN 18 // Pin A0
#define LED_PIN 14
bool ledState = LOW;
// **************************CONSTANTS********************************
char ctrlKey = KEY_LEFT_CTRL;
char shftKey = KEY_LEFT_SHIFT;
char winKey = KEY_LEFT_GUI;
// INSTANTIATE A Button OBJECT
Button button = Button();
void setup() {
button.attach( BUTTON_PIN, INPUT ); // External pull-up 10k or similar
// DEBOUNCE INTERVAL IN MILLISECONDS
button.interval(1);
// INDICATE THAT THE LOW STATE CORRESPONDS TO PHYSICALLY PRESSING THE BUTTON
button.setPressedState(LOW);
//Setup the LED :
pinMode(LED_PIN,OUTPUT);
Keyboard.begin();
}
void loop() {
// UPDATE THE BUTTON
button.update();
if ( button.pressed() ) {
// TOGGLE THE LED STATE :
ledState = !ledState; // Set ledState TO THE OPPOSITE OF ledState
digitalWrite(LED_PIN,ledState);
// Press winKey+1 on the keyboard to activate first program (left-most on Windows taskbar)
Keyboard.press(winKey);
Keyboard.press('1');
delay(100);
Keyboard.releaseAll();
delay(100);
// Keyboard.print("You pressed the button ");
// Press Ctrl+Shift+M to toggle mute in Teams
Keyboard.press(ctrlKey);
Keyboard.press(shftKey);
Keyboard.press('m');
delay(100);
Keyboard.releaseAll();
// Keyboard.end();
}
}
© 2020 notthemarsian