# Three Button Foot Switch

## Overview

https://youtu.be/fMkaawdoVkk

In this project we're making a USB foot switch with CircuitPython!

We were inspired to make a new foot switch which could be really nice for young folks and even animals.

&nbsp;

![3d_printing_hero-solo.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/740/medium640/3d_printing_hero-solo.jpg?1644249997)

For tasks that require both hands, we think using feet can help complete tasks much quicker!

We designed and 3d printed a three button foot pedal that snap fits together.

This project can be powered by either an Adafruit QT Py RP2040 or the KB2040.

CircuitPython makes USB HID project really easy to put together.

You can customize the key&nbsp;codes and set up different keyboard shortcuts or media controls like play/pause and volume.

![3d_printing_hero-use.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/739/medium640/3d_printing_hero-use.jpg?1644249926)

![3d_printing_hero-paw.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/741/medium640/3d_printing_hero-paw.jpg?1644250051)

You can 3D print the parts without any support material using your favorite filament.

The bottom features mounting holes to use M3 hardware to secure the switches and brackets.

The case is compatible with the QTPy or KB2040 board. We used the QTPy in this build.

Boards press fit into a mount that can then&nbsp;attach to the case.

&nbsp;

![3d_printing_parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/742/medium640/3d_printing_parts.jpg?1644250330)

![3d_printing_3d-parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/743/medium640/3d_printing_3d-parts.jpg?1644250277)

Top covers can then be installed to the built-in hinges on the base.&nbsp;Theres nubbin's on the sides that are press fitted into the dimples on the hinges.

The micro-switch features a bump actuator so it works nicely without the need of an additional spring!

![](https://cdn-learn.adafruit.com/assets/assets/000/108/744/medium800/3d_printing_code-medium.jpg?1644250544)

## Prerequisite Guides

If your new to electronics and soldering, I&nbsp;suggest walking through the following guides to get the basics. The Adafruit Excellent guide to soldering will walk you through process of learning how to use a soldering iron to make solid electrical connections.

- [Lemon KeyPad](https://learn.adafruit.com/qtpy-lemon-mechanical-keypad-macropad/code)
- [Single Button Foot Switch](https://learn.adafruit.com/USB-foot-switch-circuit-python)
- [Adafruit Guide to Excellent Soldering](../../../adafruit-guide-excellent-soldering?view=all)
- [Welcome to CircuitPython](../../../welcome-to-circuitpython)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/803/medium800/projects_trs-mounted-closed.jpg?1644334466)

Info: Optional TRS jacks can be used for Assistive Technology button and switches. 

## Parts
### Adafruit QT Py RP2040

[Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
What a cutie pie! Or is it... a QT Py?&nbsp;This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new [Raspberry Pi Pico](https://www.adafruit.com/pico) _and_ our [Feather...](http://www.adafruit.com/product/4884)

In Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)
![Video of hand holding a QT Py PCB in their hand. An LED glows rainbow colors.](https://cdn-shop.adafruit.com/product-videos/640x480/4900-06.jpg)

### Arcade Button and Switch Quick-Connect Wires - 0.187" (10-pack)

[Arcade Button and Switch Quick-Connect Wires - 0.187" (10-pack)](https://www.adafruit.com/product/3835)
Quick connector wire sets make wiring up our arcade-style or metal buttons quicky-quick. Each wire comes as a 'pair' with two 0.187" quick-connects pre-crimped. The wires are terminated together in a JST 2.5mm 2-pin connector. This connector will fit in 0.1" headers,...

In Stock
[Buy Now](https://www.adafruit.com/product/3835)
[Related Guides to the Product](https://learn.adafruit.com/products/3835/guides)
![Angled shot of Arcade Button and Switch Quick-Connect Wires - 0.187" (10-pack)](https://cdn-shop.adafruit.com/640x480/3835-08.jpg)

# Three Button Foot Switch

## Circuit Diagram

This provides a visual reference for wiring of the components. They aren't true to scale, just meant to be used as reference. Generic micro switches follow a standard pin out with visible markings on the body of the switch. Here's each label markings:

- (C1) – "common ground".
- (NO2) – "normally open".
- (NC3) – "normally closed".

&nbsp;

- (C 1) **Common** from micro switch to **Ground** on **QTPy**  
  
- (NO2) **Normally open** from micro switch to **#0** on on **QTPy**

![3d_printing_circuit-diagram.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/738/medium640/3d_printing_circuit-diagram.jpg?1644248983)

# Three Button Foot Switch

## CircuitPython

[CircuitPython](https://github.com/adafruit/circuitpython) is a derivative of [MicroPython](https://micropython.org) designed to simplify experimentation and education on low-cost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. Simply copy and edit files on the **CIRCUITPY** drive to iterate.

## CircuitPython Quickstart

Follow this step-by-step to quickly get CircuitPython running on your board.

[Download the latest version of CircuitPython for this board via circuitpython.org](https://circuitpython.org/board/adafruit_qtpy_rp2040/)
 **Click the link above to download the latest CircuitPython UF2 file.**

Save it wherever is convenient for you.

![install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/655/medium640/install_circuitpython_on_rp2040_RP2040_UF2_downloaded.jpg?1618943202)

![](https://cdn-learn.adafruit.com/assets/assets/000/101/680/medium800/adafruit_products_QTRP_buttons.jpg?1618956837)

To enter the bootloader, hold down the **BOOT/**** BOOTSEL button**(highlighted in red above), and while continuing to hold it (don't let go!), press and release the**reset button**(highlighted in red or blue above).&nbsp;**Continue to hold the BOOT/BOOTSEL button until the RPI-RP2 drive appears!**

If the drive does not appear, release all the buttons, and then repeat the process above.

You can also start with your board unplugged from USB, press and hold the BOOTSEL button (highlighted in red above), continue to hold it while plugging it into USB, and wait for the drive to appear before releasing the button.

A lot of people end up using charge-only USB cables and it is very frustrating! **Make sure you have a USB cable you know is good for data sync.**

You will see a new disk drive appear called **RPI-RP2**.

&nbsp;

Drag the **adafruit\_circuitpython\_etc.uf2** file to **RPI-RP2.**

![install_circuitpython_on_rp2040_RP2040_bootloader_drive.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/656/medium640/install_circuitpython_on_rp2040_RP2040_bootloader_drive.jpg?1618943666)

![install_circuitpython_on_rp2040_RP2040_drag_UF2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/657/medium640/install_circuitpython_on_rp2040_RP2040_drag_UF2.jpg?1618943674)

The **RPI-RP2** drive will disappear and a new disk drive called **CIRCUITPY** will appear.

That's it, you're done! :)

![install_circuitpython_on_rp2040_RP2040_CIRCUITPY.jpg](https://cdn-learn.adafruit.com/assets/assets/000/101/658/medium640/install_circuitpython_on_rp2040_RP2040_CIRCUITPY.jpg?1618943864)

## Safe Mode

You want to edit your **code.py** or modify the files on your **CIRCUITPY** drive, but find that you can't. Perhaps your board has gotten into a state where **CIRCUITPY** is read-only. You may have turned off the **CIRCUITPY** drive altogether. Whatever the reason, safe mode can help.

Safe mode in CircuitPython does not run any user code on startup, and disables auto-reload. This means a few things. First, safe mode _bypasses any code in_ **boot.py** (where you can set **CIRCUITPY** read-only or turn it off completely). Second, _it does not run the code in_ **code.py**. And finally, _it does not automatically soft-reload when data is written to the_ **CIRCUITPY** _drive_.

Therefore, whatever you may have done to put your board in a non-interactive state, safe mode gives you the opportunity to correct it without losing all of the data on the **CIRCUITPY** drive.

### Entering Safe Mode
To enter safe mode when using CircuitPython, plug in your board or hit reset (highlighted in red above). Immediately after the board starts up or resets, it waits 1000ms. On some boards, the onboard status LED (highlighted in green above) will blink yellow during that time. If you press reset during that 1000ms, the board will start up in safe mode. It can be difficult to react to the yellow LED, so you may want to think of it simply as a slow double click of the reset button. (Remember, a fast double click of reset enters the bootloader.)

### In Safe Mode

If you successfully enter safe mode on CircuitPython, the LED will intermittently blink yellow three times.

If you connect to the serial console, you'll find the following message.

```terminal
Auto-reload is off.
Running in safe mode! Not running saved code.

CircuitPython is in safe mode because you pressed the reset button during boot. Press again to exit safe mode.

Press any key to enter the REPL. Use CTRL-D to reload.
```

You can now edit the contents of the **CIRCUITPY** drive. Remember, _your code will not run until you press the reset button, or unplug and plug in your board, to get out of safe mode._

## Flash Resetting UF2

If your board ever gets into a really _weird_ state and CIRCUITPY doesn't show up as a disk drive after installing CircuitPython, try loading this 'nuke' UF2 to RPI-RP2. which will do a 'deep clean' on your Flash Memory. **You will lose all the files on the board** , but at least you'll be able to revive it! After loading this UF2, follow the steps above to re-install CircuitPython.

[Download flash erasing "nuke" UF2](https://cdn-learn.adafruit.com/assets/assets/000/101/659/original/flash_nuke.uf2?1618945856)
# Three Button Foot Switch

## Code

![](https://cdn-learn.adafruit.com/assets/assets/000/108/748/medium800/3d_printing_code-laptop.jpg?1644253295)

## Download Project Bundle
Once you've installed the latest version of CircuitPython onto your board, you'll need to grab the code, libraries and any assets included with the project.

Click the **&nbsp;download project bundle&nbsp;** button below to get the code, libraries and assets all in one!

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Three_Button_USB_FootSwitch/code.py

## Upload Code, Libraries and Assets

Unzip the project bundle and upload the files to the&nbsp; **CIRCUITPY** &nbsp;drive.

Your&nbsp; **CIRCUITPY&nbsp;** drive should look like this after you've uploaded the code, libraries and assets.

![](https://cdn-learn.adafruit.com/assets/assets/000/108/747/medium800/3d_printing_circuitpy-drive.jpg?1644253193)

## USB HID Keyboard and Mouse
Check out the guides linked below for more information on using the USB-HID library for CircuitPython.

[HID Keyboard Mouse Guide](https://learn.adafruit.com/circuitpython-essentials/circuitpython-hid-keyboard-and-mouse)
[ReadTheDocs – HID Library](https://circuitpython.readthedocs.io/projects/hid/en/latest/)
## Modify Controls

The three switches are assigned the consumer controls for play/pause volume up, and volume down. Adjust the following code to change the keys control or the order of the arrangement. The `buttonpins` and `buttonkeys` are ordered chronologically.

```auto
# The button pins we'll use, each will have an internal pullup
buttonpins = [board.A1, board.A2, board.A3]

# The keycode sent for each button, will be paired with a control key
buttonkeys = [
    ConsumerControlCode.PLAY_PAUSE,
    ConsumerControlCode.VOLUME_INCREMENT,
    ConsumerControlCode.VOLUME_DECREMENT
]
```

# Three Button Foot Switch

## 3D Printing

## Parts List

STL files for 3D printing are oriented to print "as-is" on FDM style machines. Parts are designed to 3D print without any support material. Original design source may be downloaded using the links below.

![3d_printing_3d-parts.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/734/medium640/3d_printing_3d-parts.jpg?1644246384)

[Edit Design Files](https://a360.co/3vkEfDm)
[Download STLs](https://www.thingiverse.com/thing:5237349)
### Slice with settings for PLA material.&nbsp;

The parts were sliced using CURA using the slice settings below.

- PLA filament 220c extruder
- 0.2 layer height
- 10% gyroid infill
- 60mm/s print speed
- 60c heated bed

![3d_printing_slice.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/735/medium640/3d_printing_slice.jpg?1644246619)

# Filaments

The filamented used in this project.

- [Evryone PLA Sparkly Glitter](https://www.amazon.com/ERYONE-Sparkly-Glitter-Printer-Filament/dp/B083K6Q9DD/)
  - Purple
  - Black
  - Red

![](https://cdn-learn.adafruit.com/assets/assets/000/108/736/medium800/3d_printing_hero-boards.jpg?1644246677)

# Three Button Foot Switch

## Assemble

## Assemble switch brackets

&nbsp;

M3 x 16mm long screws are used to attach the micro switches to the printed brackets.

&nbsp;

&nbsp;

![3d_printing_switch-screws.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/726/medium640/3d_printing_switch-screws.jpg?1644245362)

## Mount switch brackets

&nbsp;

Brackets are mounted to the base with M3 x 5mm long screws.&nbsp;

Connect the arcade quick connect wires before mounting to the base.

![3d_printing_bracket-mount.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/727/medium640/3d_printing_bracket-mount.jpg?1644245445)

![3d_printing_switch-wires-connected.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/746/medium640/3d_printing_switch-wires-connected.jpg?1644250953)

## Solder board

&nbsp;

Wires are soldered to the pins on the micro-controller.

The board is inserted into the PCB mount at an angle with the corners fitting under these clips.

The mount is then secured to the main base using hardware screws with all of the connections made.

![3d_printing_tqtpy-connections.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/728/medium640/3d_printing_tqtpy-connections.jpg?1644245510)

![3d_printing_qtpy-mounting.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/729/medium640/3d_printing_qtpy-mounting.jpg?1644245571)

## Mount board

&nbsp;

The board mount attaches to the base with two M3x5mm long screws.&nbsp;

Panel Mount 1/8" / 3.5mm TRS Audio Jack Connector fit next to the USB port on the case.

![3d_printing_base-ready.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/730/medium640/3d_printing_base-ready.jpg?1644245630)

![projects_trs-mounted-2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/804/medium640/projects_trs-mounted-2.jpg?1644334620)

## Attach lid

&nbsp;

The top covers can then be installed to the built-in hinges on the base.

Theres nubbin's on the sides that are press fitted into the dimples on the hinges.

The micro-switch features a bump actuator so it works nicely without the need of an additional spring.

![3d_printing_lid-attaching.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/731/medium640/3d_printing_lid-attaching.jpg?1644245802)

![3d_printing_lid-attach.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/732/medium640/3d_printing_lid-attach.jpg?1644245834)

## Complete!

&nbsp;

Additional rubber feet make it grip to any hard surface and they just stick to the bottom of the case.

This&nbsp;project uses code from the Lemon KeyPad: [https://learn.adafruit.com/qtpy-lemon-mechanical-keypad-macropad/code](https://learn.adafruit.com/qtpy-lemon-mechanical-keypad-macropad/code)

We hope this inspires you to try out CircuitPython for your next USB controller project.

![projects_feet-attached.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/805/medium640/projects_feet-attached.jpg?1644334699)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/733/medium800/3d_printing_hero-solo.jpg?1644246306)


## Featured Products

### Micro Switch - Premium Zippy 3-Terminal

[Micro Switch - Premium Zippy 3-Terminal](https://www.adafruit.com/product/817)
Micro-switches are often found in arcade buttons and joysticks but they're also really handy in any kind of mechatronics project or when you need a basic sensor. They are always 'tactile' (clicky feeling), and 'momentary' (the switch closes when pressed, then snaps open...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/817)
[Related Guides to the Product](https://learn.adafruit.com/products/817/guides)
### Adafruit QT Py RP2040

[Adafruit QT Py RP2040](https://www.adafruit.com/product/4900)
What a cutie pie! Or is it... a QT Py?&nbsp;This diminutive dev board comes with one of our new favorite chip, the RP2040. It's been made famous in the new [Raspberry Pi Pico](https://www.adafruit.com/pico) _and_ our [Feather...](http://www.adafruit.com/product/4884)

In Stock
[Buy Now](https://www.adafruit.com/product/4900)
[Related Guides to the Product](https://learn.adafruit.com/products/4900/guides)
### Arcade Button and Switch Quick-Connect Wires - 0.187" (10-pack)

[Arcade Button and Switch Quick-Connect Wires - 0.187" (10-pack)](https://www.adafruit.com/product/3835)
Quick connector wire sets make wiring up our arcade-style or metal buttons quicky-quick. Each wire comes as a 'pair' with two 0.187" quick-connects pre-crimped. The wires are terminated together in a JST 2.5mm 2-pin connector. This connector will fit in 0.1" headers,...

In Stock
[Buy Now](https://www.adafruit.com/product/3835)
[Related Guides to the Product](https://learn.adafruit.com/products/3835/guides)
### Little Rubber Bumper Feet - Pack of 4

[Little Rubber Bumper Feet - Pack of 4](https://www.adafruit.com/product/550)
Keep your electronics from going barefoot, give them little rubber feet! These small sticky bumpers are our favorite accessory for any electronic kit or device. They are sticky, but not impossible to remove. They're small enough to fit onto any board, and have just enough height to give...

In Stock
[Buy Now](https://www.adafruit.com/product/550)
[Related Guides to the Product](https://learn.adafruit.com/products/550/guides)
### Panel Mount 1/8" / 3.5mm TRS Audio Jack Connector

[Panel Mount 1/8" / 3.5mm TRS Audio Jack Connector](https://www.adafruit.com/product/3692)
What _is_ this TRS bit? **T** urtle **R** ock **S** tudios? **T** ransmission **R** aman **S** pectroscopy? Not quite, more...

In Stock
[Buy Now](https://www.adafruit.com/product/3692)
[Related Guides to the Product](https://learn.adafruit.com/products/3692/guides)

## Related Guides

- [Adafruit QT Py RP2040](https://learn.adafruit.com/adafruit-qt-py-2040.md)
- [Adafruit CircuitPython Wii Classic Controller Library](https://learn.adafruit.com/adafruit-circuitpython-wii-classic-controller-library.md)
- [NeoPixel Mini VU Meter](https://learn.adafruit.com/neopixel-mini-vu-meter.md)
- [3D Scans for Low Poly Statues](https://learn.adafruit.com/low-poly-3d-scans-for-3d-printing.md)
- [Toddler Timer](https://learn.adafruit.com/toddler-timer.md)
- [MIDI Foot Pedal](https://learn.adafruit.com/midi-foot-pedal.md)
- [PlayStation Spinner Controller](https://learn.adafruit.com/playstation-spinner-controller.md)
- [Kitty Toe Bean Keypad with Color TFT](https://learn.adafruit.com/kitty-toe-bean-paw-keypad-color-tct.md)
- [LED Noodle Holiday Tree](https://learn.adafruit.com/led-noodle-tree.md)
- [SNES Mouse to USB HID with CircuitPython](https://learn.adafruit.com/snes-mouse-to-usb-hid-with-circuitpython.md)
- [Owl IR TV Remote](https://learn.adafruit.com/owl-ir-tv-remote.md)
- [NeXT Bus Mouse to USB HID with CircuitPython](https://learn.adafruit.com/next-bus-mouse-to-usb-hid-with-circuitpython.md)
- [LEGO Set Lighting](https://learn.adafruit.com/lego-set-lighting.md)
- [MIDI for Makers](https://learn.adafruit.com/midi-for-makers.md)
- [Customizing USB Devices in CircuitPython](https://learn.adafruit.com/customizing-usb-devices-in-circuitpython.md)
- [LED Neon Signs with NeoPixels](https://learn.adafruit.com/led-neon-signs-with-neopixels.md)
