USB Pedal Based on Rpi Pico

by Galopago in Circuits > Raspberry Pi

1956 Views, 14 Favorites, 0 Comments

USB Pedal Based on Rpi Pico

USB_PEDAL_RPI_PICO_MEDIUM.jpg

USB pedals (or any other momentary switches) who emulates keyboard keypress or combination of keys. Handy to use with video edition software to pause/play without moving the hands away from the keyboard or mouse, it can also be used by videoconferencing software to mute quickly. There’s no need for special application to download initial firmware nor for keys setup (only a simple text editor needed). Works with almost any operating system, even with android devices using an OTG USB adapter.

Key component: Rpi Pico.

Concept

A lot of USB programmable pedals on the market need to install an application for configuration. Usually this app is only for Windows and came poorly translated (if translated at all). This is a pitfall for Linux or Mac users, who have only two options: To install a Windows virtual machine or ask a favor to a Windows user for pedal setup.

Here come to the rescue Raspberry Pi Pico, for two big reasons: USB native interface, so no programmer or additional hardware needed for firmware download and the most important: CircuitPython support. Programming could be “on the fly” without compiling-and-download during the debug phase. So Rpi Pico is the best candidate for a DIY pedal.

Another additional advantage over commercial USB pedals, the pedal itself can be replaced for a more robust one, without touching the circuit. Another kind of switches could be used, so operation with different parts of the body is possible. The amount of switches to be installed is only limited by Rpi Pico GPIO pins and the space available on the enclosure.

The circuit is built using TUSISTEMITA hardware prototyping system, which provides different kinds of prebuilt modules which allows to build an electronic project without soldering, but making it very robust and expandable. All the parts are enclosed in a dustproof and waterproof IP65 box. This enclosure gives an “industrial look” to the project and also adds mechanical strength to withstand abuses. The external electrical connections (pedals, and USB) were fitted with IP accessories to provide a good seal.

Key Features

rpi_pico_usb_keyboard.png
  • Developed using CircuitPython, friendly and easy to learn
  • Compatible with the most common operating systems
  • No need to install apps for initial firmware download
  • Key configuration done in a text file
  • Splash resistant and shockproof
  • Detachable and replaceable pedals
  • Built using hardware prototyping system
  • Powered by USB, no additional power source needed

The hardware is pretty simple, only requires a Rpi Pico and switches connected between GPIO and ground. Internal pull-up resistors used. Power and data via USB cable

What Is CircuitPython?

In Adafruit Industres words, makers of CircuitPython:

CircuitPython is a programming language designed to simplify experimenting and learning to program on low-cost microcontroller boards. It makes getting started easier than ever with no upfront desktop downloads needed. Once you get your board set up, open any text editor, and get started editing code. It’s that simple.

Other reasons to use CircuitPython include:

  • You want to get up and running quickly. Create a file, edit your code, save the file, and it runs immediately. There is no compiling, no downloading and no uploading needed.
  • You’re new to programming. CircuitPython is designed with education in mind. It’s easy to start learning how to program and you get immediate feedback from the board.
  • Easily update your code. Since your code lives on the disk drive, you can edit it whenever you like, you can also keep multiple files around for easy experimentation.
  • The serial console and REPL. These allow for live feedback from your code and interactive programming.
  • File storage. The internal storage for CircuitPython makes it great for data-logging, playing audio clips, and otherwise interacting with files.
  • Strong hardware support. There are many libraries and drivers for sensors, breakout boards and other external components.
  • It’s Python! Python is the fastest-growing programming language. It’s taught in schools and universities. CircuitPython is almost-completely compatible with Python. It simply adds hardware support.


Software

Sample application presented here is composed of two tasks: Initialize GPIO according to the configuration file and then runs an endless loop verifying for switch closing to send its respective keycode. Software debouncing function was used to avoid false key press. Rpi Pico onboard LED lights when whatever configured switch closes.

The configuration file structure is very simple. First line GPIOS to use, second line keycode to send, and third line modifier keycode (I.E SHIFT, CONTROL, ALT). If during initialization the config file isn’t found, the program will assume some default values. More GPIOS can be added to the config file, so 3, 4 or mode pedals could be plugged.

Circuit Assembly

USB_PEDAL_PICO_DEBUG_MEDIUM.jpg
USB_PEDAL_PICO_PARTS_MEDIUM.jpg
USB_PEDAL_PICO_WIRED_MEDIUM.jpg

The circuit was built using components of TUSISTEMITA, like enclosure backplate, and Rpi Pico screw terminal breakboard.

Once the app is downloaded for the first time, and electrical connections verified, the backplate could be attached to the enclosure hassle free. Just unplug USB cable and debug switches’ screw terminals, screw backplate to enclosure and reconnect cables again.

Enclosure Connections

USB_PEDAL_PICO_AVIATION_MEDIUM.jpg
USB_PEDAL_PICO_PANEL_MEDIUM.jpg
USB_PEDAL_PICO_PRINTER_MEDIUM.jpg

USB printer connector (Type B) was chosen because is very robust and intuitive. This specific connector is designed for panel mounting and sports 4 metal pins (VCC,USB+,USB-,GND) that must be soldered to a Micro USB extension cable to plug to the Rpi Pico. Pedals use circular aviation connectors.


Once the enclosure is closed, firmware updates could be done modifying the CircuitPython file, or via interactive environment. For a CircuitPython re-installation or Rpi Pico “format”, the enclosure must be open to access bootsel button.

Bill of Materials

TUSISTEMITA Blocks

  • A01 Backplate for 158x90x60mm enclosureA01
  • C11 screw terminal breakout board for Rpi PicoC11

Software Sources

Optional Components