Skip to content

Instantly share code, notes, and snippets.

@darksidelemm
Last active March 19, 2022 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darksidelemm/eeb25a03b5600cc0690cf1e11bf429a5 to your computer and use it in GitHub Desktop.
Save darksidelemm/eeb25a03b5600cc0690cf1e11bf429a5 to your computer and use it in GitHub Desktop.
/*
Heil Dual-Switch Footswitch Momentary Mute Button
Mark Jessop < vk5qi@rfhead.net >
Mutes system audio on Windows machine when a footswitch is pressed, then un-mutes when
the switch is released. This is useful when listening via a remote SDR on a PC, which
can also hear your own transmissions (helps avoid echo!)
Hardware:
* Pololu A-Star 32U4 (though any other ATMega32U4 based board should work)
* Source: https://www.littlebird.com.au/products/a-star-32u4-micro
* Jiffy Box
* RCA socket: Centre pin connected to Pin 0 on the A-Star, Shield connected to GND.
* Heil FS-2 Footswitch
* Source: https://www.strictlyham.com.au/heil-fs-2
* NOTE: This footswitch has two outputs! One (black wire) goes to my radio, and the
other (red wire) goes to this box.
Extra libraries you will need to install into Arduino:
* 'HID-Project' we use this class: https://github.com/NicoHood/HID/wiki/Consumer-API
* Board library for whatever board you are using.
Note that since switching to using the mute HID button, this acts as a toggle - so you will
need to be sure your audio is unmuted before you press the footswitch.
*/
#include "HID-Project.h"
const int buttonPin = 0; // Input pin connected to the switch.
int previousButtonState = HIGH; // for checking the state of a pushButton
void setup() {
// make the pushButton pin an input:
pinMode(buttonPin, INPUT_PULLUP);
// initialize control over the keyboard:
Consumer.begin();
}
void loop() {
// read the pushbutton:
int buttonState = digitalRead(buttonPin);
// if the button state has changed,
if ((buttonState != previousButtonState)
// and it's currently pressed:
&& (buttonState == LOW)) {
// Send the 'mute' signal
Consumer.write(MEDIA_VOLUME_MUTE);
delay(100); // This delay acts to de-bounce
} else if ((buttonState != previousButtonState)
// and it's currently pressed:
&& (buttonState == HIGH)) {
// Send the mute signal again.
Consumer.write(MEDIA_VOLUME_MUTE);
delay(100);
}
// save the current button state for comparison next loop
previousButtonState = buttonState;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment