/footswitch

A USB footswitch for push-to-talk in Discord and other voice apps

Primary LanguageRustApache License 2.0Apache-2.0

footswitch

Free up your hands, and your keybinds -- PTT with your foot!

footswitch is a 1-key keyboard for push-to-talk in Discord (and other voice-chat apps), based on Arduino, that you can build yourself.

Footswitch built on Pro Micro

The parts needed to build the unit shown above cost about 10 USD, plus about 5 USD in shipping costs. If you build more than one, it's easy to amortise the shipping costs.

How to build the footswitch

Parts list

  • An Arduino (ATmega32U4 strongly recommended).

    Small Arduino boards based on ATmega32U4 without headers, such as the Arduino Micro are best, because this gives you the most options. Similar third-party boards based on the ATmega32U4 like Adafruit's ItsyBitsy 32U4 and SparkFun Pro Micro should also work.

    Avoid the serial-only boards that have a USB-TTL chip (eg: CH341, FT232R, PL2303) because they only work as a USB serial device, require drivers and a client to simulate keypresses.

    Arduino boards that only support "USB programming" won't work at all. This only affects some old, third-party boards.

  • A foot / pedal switch.

    This should have two or three wires, and close the circuit when the switch is pressed.

    The switch needs to be rated to at least 5V 40mA.

    Using a higher rated switch (eg: 240V 10A) is fine, and probably mechanically-ideal for something you're going to push with your foot!

  • Clear heat-shrink (optional).

    If you have a small Arduino board without pin headers, you can wrap it with clear heat shrink to prevent it shorting on things.

    You'll also need a heat gun, butane torch or lighter to melt the heatshrink.

    Tip: heatshrink sizes are the circular diameter of the heatshrink. When laid flat (to go over a board), this is about half the circumference (ie: W = D * π / 2) – so 16mm heatshrink is about 25mm wide!

  • Anti-slip mat (optional).

    Many foot switches have rubber feet on them to stop them slipping, but these can come out easily (depending on build quality).

    Sticking some anti-slip mat to the foot switch is more reliable.

If you don't have a soldering iron, you'll need to get a board with headers, and a switch with appropriate connectors.

Wiring the board

Wiring is identical for both versions of the code, a normally-open foot switch between D2 and GND:

                   ╔═════════╗
  ┌─ COM ──────── D2         ║
  ●                ║         USB
 ╱                 ║ Arduino ║
╱                  ║  Board  ║
  ●                ║         ║
  └─ N/O ─────── GND         ║
Switch             ╚═════════╝

The software uses the Arduino's internal pull-up resistor on D2, so you don't need to wire any additional external resistor.

You could connect the foot switch using jumper leads, solder its leads directly to the board, or add your own connector (eg: RCA).

For smaller boards, once soldered up, you can wrap the board in clear heat-shrink, to avoid it shorting on other things. Just cut a hole for the board's reset button!

Arduino code

There is a keyboard and serial version of the code in this repository:

Version Arduino support USB device class Footswitch client
keyboard ATmega32U4 and SAMD only HID keyboard + serial optional
serial Any Arduino with serial USB serial required

Building and uploading the Arduino code requires the Arduino IDE.

  1. Connect your Arduino board for the footswitch to your computer via USB.

  2. For safety, temporarily disconnect any other Arduino boards (or USB serial devices) you have connected to your computer.

  3. Open keyboard/keyboard.ino or serial/serial.ino in the Arduino IDE.

  4. In Arduino IDE's Tools menu, select the correct Board, Processor and (serial) Port.

    If using a third-party board, you might need to install a package using Board Manager -- check the manufacturer's website for instructions.

    Uploading using the wrong settings might appear to upload correctly, but then the device may not show up anymore, and require a reset and re-flash to correct. See the manufacturer's website for instructions if this happens to you.

  5. Press the Upload button (or SketchUpload).

keyboard version (recommended)

This version acts as a real USB HID keyboard device, so doesn't require any "client" running on your computer to work.

It also exposes a USB serial device (CDC ACM) which can work with the serial version's client.

The first time you use the device on macOS, Keyboard Set-up Assistant will pop up. Press any key on any keyboard to skip the auto-detection process, and then set the keyboard type to ANSI.

  • Ardiuno support: Any that provide a serial connection.
  • Serial client: required
  • OS support: macOS (limited), Windows

This version acts as a serial device, and requires a client to convert this into keypresses.

This is provided for experiments – if you happen to have an Arduino that you want to try this out on, but its microcontroller doesn't support USB.

Client

For the serial version to work, you need a way to send keyboard events to applications. This is done by the footswitch client.

The keyboard version also acts as a serial device, which is useful for microphone control.

More information is available in the client's README.

Setting up Discord

Note: If you are using the serial version, you need to run the client for this to work!

Warning: Due to a bug in Discord for macOS, you cannot use the serial version with keyboard emulation to control Discord PTT.

Both the keyboard version of the Arduino code, and the client use F13 as its default key bind.

In Discord:

  1. Open settings
  2. Click Voice & Video (under App Settings)
  3. Set Input mode to Push to Talk
  4. Click Edit keybind
  5. Press the footswitch

At this point, the shortcut should show up as F13.

License and acknowledgements

Code for the Arduino (.ino files) is based example code from the Arduino open source project, released into the public domain. The modified Arduino code used in this project may be used under the same terms, Creative Commons Zero 1.0, or the Apache 2.0 license (at your choice).

All other files, including the client, are released under the Apache 2.0 license.