Skip to content

Instantly share code, notes, and snippets.

@kingfisher1234
Last active January 12, 2022 18:11
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kingfisher1234/caf351bed786f9050e1fa28c3352ded9 to your computer and use it in GitHub Desktop.
Save kingfisher1234/caf351bed786f9050e1fa28c3352ded9 to your computer and use it in GitHub Desktop.
Physical mute button for Zoom using an ATTiny85/Digispark and the Micronucleus bootloader to allow programming with the Arduino IDE - Mac Version
/*
Thanks to Elliotmade for the inspiration on this project
https://elliotmade.com/2020/04/23/physical-mute-button-for-zoom-meetings/
Refactored by HaxNobody to extend functionalty
https://gist.github.com/HaxNobody/7bde369d7a41348b8b91c1a4f358ea4a#file-zoommutebutton-ino
This program will send USB HID keyboard presses to bring the Zoom window into
the foreground and activate microphone and video functions.
* A momentary press on button 1 will toggle mute on or off.
* Press and hold button 1 to close zoom (Zoom Needs to be in focus on a Mac (Or you will close a different window)).
*/
#include <DigiKeyboard.h> // Library for sending keystrokes as an HID device over USB
#include <OneButton.h> // Library for button input functions
#define LedBreatheSpeed 12 // Speed of LED breathing animation in BPM
#define LedMinBrightness 5 // Minimum brightness value
#define MOD_CMD_LEFT 0x00000008
OneButton button1(
0, // Pin Number
true, // Input is active LOW
true // Enable internal pull-up resistor
);
OneButton button2(
2, // Pin Number
true, // Input is active LOW
true // Enable internal pull-up resistor
);
void setup() {
button1.attachClick(button1click); // Set up button 1 for Zoom mute toggle function
button1.attachLongPressStart(button1longPressStart); // Set up button 1 for Zoom temporary unmute function
// button1.attachLongPressStop(button1longPressStop); // Set up button 1 for Zoom temporary unmute release function
button1.setPressTicks(1000); // Reduce long-press delay for button 1 to make temporary unmute more responsive
DigiKeyboard.delay(50); // Delay before entering loop
pinMode(1, OUTPUT); // Initialize LED pin
}
void loop() {
DigiKeyboard.update(); // Maintain USB communication
button1.tick(); // Check status of buttons in a continuous loop
button2.tick();
}
// This function will be called when button 1 is pressed for more than 50ms and less than 300ms.
void button1click() {
DigiKeyboard.sendKeyStroke(0); // Clear any current key presses
//DigiKeyboard.delay(50); // Give Zoom a chance to get into the foreground
DigiKeyboard.sendKeyStroke(KEY_A, MOD_GUI_LEFT | MOD_CMD_LEFT | MOD_SHIFT_LEFT); // Toggle mute on or off in Zoom
}
// This function will be called when button 1 is pressed and held down for more than 300ms.
void button1longPressStart() {
DigiKeyboard.sendKeyStroke(0); // Clear any current key presses
//DigiKeyboard.delay(50);
//DigiKeyboard.sendKeyStroke(KEY_F, MOD_GUI_LEFT | MOD_CMD_LEFT | MOD_SHIFT_LEFT); // Enter or exit full screen
//DigiKeyboard.sendKeyStroke(KEY_ENTER);
//DigiKeyboard.sendKeyStroke(0); // Clear any current key presses
DigiKeyboard.delay(350);
DigiKeyboard.sendKeyStroke(KEY_W, MOD_GUI_LEFT | MOD_CMD_LEFT );
DigiKeyboard.delay(350);
DigiKeyboard.sendKeyStroke(KEY_ENTER);
DigiKeyboard.delay(350);
}
// This function will be called when button 1 is released after being held down.
//void button1longPressStop() {
// DigiKeyboard.delay(300); // Delay to prevent cutting off the speaker's last word
// DigiKeyboard.sendKeyPress(0); // Release space key to re-mute Zoom after temporary unmute
//}
@damenleeturks
Copy link

Did you drop the FastLED stuff for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment