Last active
February 14, 2021 19:52
-
-
Save misterhay/4699d240513c2960ae8aa141a9cc259f to your computer and use it in GitHub Desktop.
Videoconference controller with arcade buttons and Teensy microcontroller (Arduino)
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
// Teensy 2 Videoconference Buttons Controller | |
// Choose Keyboard from the "Tools > USB Type" menu | |
// buttons connected to 6 pins, and a switch for different programs | |
#include <Bounce.h> | |
Bounce button0 = Bounce(2, 50); | |
Bounce button1 = Bounce(1, 100); // this button was too sensitive | |
Bounce button2 = Bounce(0, 50); | |
Bounce button3 = Bounce(3, 50); | |
Bounce button4 = Bounce(14, 50); | |
Bounce button5 = Bounce(13, 50); | |
void setup() { | |
pinMode(0, INPUT_PULLUP); | |
pinMode(1, INPUT_PULLUP); | |
pinMode(2, INPUT_PULLUP); | |
pinMode(3, INPUT_PULLUP); | |
pinMode(13, INPUT_PULLUP); | |
pinMode(14, INPUT_PULLUP); | |
pinMode(4, INPUT_PULLUP); // switch | |
} | |
void loop() { | |
// Update buttons | |
button0.update(); | |
button1.update(); | |
button2.update(); | |
button3.update(); | |
button4.update(); | |
button5.update(); | |
int switchState = digitalRead(4); // switchState == 1 for Meet, 0 for Zoom | |
// Check each button | |
if (button0.fallingEdge()) { // toggle microphone mute | |
if (switchState) { | |
Keyboard.press(MODIFIERKEY_CTRL); | |
Keyboard.press(KEY_D); | |
} | |
else { | |
Keyboard.press(MODIFIERKEY_ALT); | |
Keyboard.press(KEY_A); | |
} | |
Keyboard.releaseAll(); | |
} | |
if (button1.fallingEdge()) { // toggle camera on/off | |
if (switchState) { | |
Keyboard.press(MODIFIERKEY_CTRL); | |
Keyboard.press(KEY_E); | |
} | |
else { | |
Keyboard.press(MODIFIERKEY_ALT); | |
Keyboard.press(KEY_V); | |
} | |
Keyboard.releaseAll(); | |
} | |
if (button2.fallingEdge()) { // toggle chat | |
if (switchState) { | |
Keyboard.press(MODIFIERKEY_CTRL); | |
Keyboard.press(MODIFIERKEY_ALT); | |
Keyboard.press(KEY_C); | |
} | |
else { | |
Keyboard.press(MODIFIERKEY_ALT); | |
Keyboard.press(KEY_H); | |
} | |
Keyboard.releaseAll(); | |
} | |
if (button3.fallingEdge()) { | |
if (switchState) { | |
Keyboard.press(KEY_PAGE_UP); | |
} | |
else { | |
Keyboard.press(KEY_PAGE_UP); | |
} | |
Keyboard.releaseAll(); | |
} | |
if (button4.fallingEdge()) { | |
if (switchState) { | |
Keyboard.press(KEY_PAGE_DOWN); | |
} | |
else { | |
Keyboard.press(KEY_PAGE_DOWN); | |
} | |
Keyboard.releaseAll(); | |
} | |
if (button5.fallingEdge()) { // raise or lower hand | |
if (switchState) { | |
Keyboard.press(KEY_SCROLL_LOCK); | |
} | |
else { | |
Keyboard.press(MODIFIERKEY_ALT); | |
Keyboard.press(KEY_Y); | |
} | |
Keyboard.releaseAll(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment