# USB Foot Switch Controller in CircuitPython

## Overview

https://www.youtube.com/watch?v=gzG1hSg30aY

## USB Circuit Python Controllers

In this guide, we'll build a USB foot switch controller. This can be used as an addition to your keyboard or as a way to free up your hands. I'm using it to do overhead photography so I can trigger the camera and use my hands at the same time.

It’s powered by Adafruit’s Trinket M0 which is a tiny microcontroller that can run CircuitPython. Just connect over USB and load it as a flash drive. All of the code and libraries are accessible on the drive so you can make small edits and iterate quickly. The Adafruit HID library simulates USB devices so it can send keypress just like a mouse and keyboard.

![](https://cdn-learn.adafruit.com/assets/assets/000/052/021/medium800/3d_printing_hero-nofoot-b.jpg?1521165655)

## 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.

- [Adafruit Guide to Excellent Soldering](../../../adafruit-guide-excellent-soldering?view=all)
- [Welcome to CircuitPython](../../../welcome-to-circuitpython)
- [Collin's Lab: Soldering](../../../collins-lab-soldering)

![](https://cdn-learn.adafruit.com/assets/assets/000/051/979/medium800/3d_printing_parts.jpg?1521058699)

## Electronic Components

The Trinket M0 and Foot Switch are the main electronic components used in this project.

### Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE

[Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE](https://www.adafruit.com/product/3500)
The&nbsp;Adafruit Trinket M0 may be small, but do not be fooled by its size! It's a tiny microcontroller board, built around the Atmel ATSAMD21, a little chip with _a lot_ of power. We wanted to design a microcontroller board that was small enough to fit into any project, and low...

In Stock
[Buy Now](https://www.adafruit.com/product/3500)
[Related Guides to the Product](https://learn.adafruit.com/products/3500/guides)
![Manicured hand holding Trinket M0.](https://cdn-shop.adafruit.com/640x480/3500-04.jpg)

## Hardware and Supplies

Just a few screws, wires and some handy supplies.&nbsp;

### Part: M2.5 x .45 x 5mm
quantity: 4
Metric Flat Head Phillips Machine Screws
[M2.5 x .45 x 5mm](https://www.albanycountyfasteners.com/2-5-MM-x-45-Phillips-Flat-Head-Machine-Screw-p/1011-1002.htm)

### Part: #4-40 x 5/8"
quantity: 2
Imperial Flat Head Phillips Machine Screws
[#4-40 x 5/8"](https://www.albanycountyfasteners.com/Phillips-Pan-Head-Machine-Screw-Stainless-4-40-p/470000.htm)

### Silicone Cover Stranded-Core Wire - 25ft 26AWG - Black

[Silicone Cover Stranded-Core Wire - 25ft 26AWG - Black](https://www.adafruit.com/product/2517)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

In Stock
[Buy Now](https://www.adafruit.com/product/2517)
[Related Guides to the Product](https://learn.adafruit.com/products/2517/guides)
![Black stranded-core wire on a reel.](https://cdn-shop.adafruit.com/640x480/2517-01.jpg)

### Solder Spool - 1/4 lb SAC305 RoHS lead-free /  0.031" rosin-core

[Solder Spool - 1/4 lb SAC305 RoHS lead-free /  0.031" rosin-core](https://www.adafruit.com/product/734)
If you want to make a kit you'll need some solder. This 1/4 lb (about 110 gram) spool is just the right amount, not too much (like 1 lb spools) and not too little (like those little 'pocket clip' vials). This spool of solder is 0.031" in diameter, with the 'industry...

In Stock
[Buy Now](https://www.adafruit.com/product/734)
[Related Guides to the Product](https://learn.adafruit.com/products/734/guides)
![Solder Spool - 1/4 lb SAC305 RoHS lead-free / 0.031" rosin-core .](https://cdn-shop.adafruit.com/640x480/734-03.jpg)

### Multi-Colored Heat Shrink Pack - 3/32" + 1/8" + 3/16" Diameters

[Multi-Colored Heat Shrink Pack - 3/32" + 1/8" + 3/16" Diameters](https://www.adafruit.com/product/1649)
Heat shrink is the duct tape of electronics which I guess makes this heat shrink the colorful and exciting duct tape they sell&nbsp;at craft stores. &nbsp;This heat shrink comes in six different colors - red, blue, green, yellow, white and the traditional black.

Each pack contains ten...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1649)
[Related Guides to the Product](https://learn.adafruit.com/products/1649/guides)
![Array of many colorful heatshrink tubes.](https://cdn-shop.adafruit.com/640x480/1649-00.jpg)

### Part: Spring Kit
quantity: 1
Spring Kit
[Spring Kit](https://amzn.to/3N2IBnD)

## Cool Tools!

These help make the project a smooth building experience. You don't need them all of them, but I recommend them.

### Hakko Professional Quality 20-30 AWG Wire Strippers

[Hakko Professional Quality 20-30 AWG Wire Strippers](https://www.adafruit.com/product/527)
These are the finest wire strippers we have used, and if you have to do a lot of wiring, you will agree! They have soft rounded grips - very comfortable to use, and precision ground notches that do a perfect job every time. No more yanking or twisting to strip wires cleanly and quickly.<br...></br...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/527)
[Related Guides to the Product](https://learn.adafruit.com/products/527/guides)
![Red and black multi-size wire stripplers, closed](https://cdn-shop.adafruit.com/640x480/527-02.jpg)

### Flush diagonal cutters

[Flush diagonal cutters](https://www.adafruit.com/product/152)
These are the best diagonal cutters, large super-comfortable grip to use and have strong nippers for perfect trimming of wires and leads. I've used my pair every day for years.

In Stock
[Buy Now](https://www.adafruit.com/product/152)
[Related Guides to the Product](https://learn.adafruit.com/products/152/guides)
![Red and black diagonal flush cutters](https://cdn-shop.adafruit.com/640x480/152-02.jpg)

### Helping Third Hand Magnifier W/Magnifying Glass Tool

[Helping Third Hand Magnifier W/Magnifying Glass Tool](https://www.adafruit.com/product/291)
The classic 'third hand tool,' as seen on every desk! We have one next to our [Panavise jr](//www.adafruit.com/products/151), they complement each other well. This tool is good for holding small PCBs and wires for tinning or soldering to parts.

&nbsp;

- Every...

In Stock
[Buy Now](https://www.adafruit.com/product/291)
[Related Guides to the Product](https://learn.adafruit.com/products/291/guides)
![Third Hand Magnifier with two alligator grabbers and Magnifying Glass](https://cdn-shop.adafruit.com/640x480/291-01.jpg)

![](https://cdn-learn.adafruit.com/assets/assets/000/052/066/medium800/3d_printing_hero-foot-upright.jpg?1521247376)

- [Next Page](https://learn.adafruit.com/usb-foot-switch-circuit-python/circuit-diagram.md)

## Guide Products

### Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE

[Adafruit Trinket M0 - for use with CircuitPython & Arduino IDE](https://www.adafruit.com/product/3500)
The&nbsp;Adafruit Trinket M0 may be small, but do not be fooled by its size! It's a tiny microcontroller board, built around the Atmel ATSAMD21, a little chip with _a lot_ of power. We wanted to design a microcontroller board that was small enough to fit into any project, and low...

In Stock
[Buy Now](https://www.adafruit.com/product/3500)
[Related Guides to the Product](https://learn.adafruit.com/products/3500/guides)
### 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)
### Silicone Cover Stranded-Core Wire - 25ft 26AWG - Black

[Silicone Cover Stranded-Core Wire - 25ft 26AWG - Black](https://www.adafruit.com/product/2517)
Silicone-sheathing wire is super-flexible and soft, and its also strong! Able to handle up to 200°C and up to 600V, it will do when PVC covered wire wimps out. We like this wire for being extremely supple and flexible, so it is great for wearables or projects where the wire-harness has to...

In Stock
[Buy Now](https://www.adafruit.com/product/2517)
[Related Guides to the Product](https://learn.adafruit.com/products/2517/guides)
### Solder Spool - 1/4 lb SAC305 RoHS lead-free /  0.031" rosin-core

[Solder Spool - 1/4 lb SAC305 RoHS lead-free /  0.031" rosin-core](https://www.adafruit.com/product/734)
If you want to make a kit you'll need some solder. This 1/4 lb (about 110 gram) spool is just the right amount, not too much (like 1 lb spools) and not too little (like those little 'pocket clip' vials). This spool of solder is 0.031" in diameter, with the 'industry...

In Stock
[Buy Now](https://www.adafruit.com/product/734)
[Related Guides to the Product](https://learn.adafruit.com/products/734/guides)
### Multi-Colored Heat Shrink Pack - 3/32" + 1/8" + 3/16" Diameters

[Multi-Colored Heat Shrink Pack - 3/32" + 1/8" + 3/16" Diameters](https://www.adafruit.com/product/1649)
Heat shrink is the duct tape of electronics which I guess makes this heat shrink the colorful and exciting duct tape they sell&nbsp;at craft stores. &nbsp;This heat shrink comes in six different colors - red, blue, green, yellow, white and the traditional black.

Each pack contains ten...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1649)
[Related Guides to the Product](https://learn.adafruit.com/products/1649/guides)
### Hakko Professional Quality 20-30 AWG Wire Strippers

[Hakko Professional Quality 20-30 AWG Wire Strippers](https://www.adafruit.com/product/527)
These are the finest wire strippers we have used, and if you have to do a lot of wiring, you will agree! They have soft rounded grips - very comfortable to use, and precision ground notches that do a perfect job every time. No more yanking or twisting to strip wires cleanly and quickly.<br...></br...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/527)
[Related Guides to the Product](https://learn.adafruit.com/products/527/guides)
### Flush diagonal cutters

[Flush diagonal cutters](https://www.adafruit.com/product/152)
These are the best diagonal cutters, large super-comfortable grip to use and have strong nippers for perfect trimming of wires and leads. I've used my pair every day for years.

In Stock
[Buy Now](https://www.adafruit.com/product/152)
[Related Guides to the Product](https://learn.adafruit.com/products/152/guides)
### Adjustable 30W 110V soldering iron

[Adjustable 30W 110V soldering iron](https://www.adafruit.com/product/180)
This 'pen-style' soldering iron is just about the best entry-level tool I've seen. It's not as powerful as a Weller WES51 but it _is_ self-contained and easy to use. With proper care, it will last for many years. Turn it off when not in use, clean the plated tip with a...

No Longer Stocked
[Buy Now](https://www.adafruit.com/product/180)
[Related Guides to the Product](https://learn.adafruit.com/products/180/guides)

## Related Guides

- [Adafruit Trinket M0](https://learn.adafruit.com/adafruit-trinket-m0-circuitpython-arduino.md)
- [Star Fragment IoT Lamp](https://learn.adafruit.com/star-fragment-iot-lamp.md)
- [3D Printed Starro Face Mask](https://learn.adafruit.com/3d-printed-starro-face-mask.md)
- [JOY Controller for Adafruit Feather](https://learn.adafruit.com/joy-controller-feather.md)
- [NeoPixel GoPro Lens Light](https://learn.adafruit.com/neopixel-gopro-lens-light.md)
- [LEGO Compatible Crickit Rover](https://learn.adafruit.com/lego-compatible-crickit-rover.md)
- [nOOds LED CV Signal Visualizers](https://learn.adafruit.com/noods-led-synth-cv-visualizers.md)
- [LED Harness Bra](https://learn.adafruit.com/neopixel-led-harness-bra.md)
- [Which CircuitPython Board is Right for You?](https://learn.adafruit.com/choose-your-circuitpython-board.md)
- [I Vote(d) Pin](https://learn.adafruit.com/i-vote-d-pin.md)
- [Gmailbox](https://learn.adafruit.com/gmailbox.md)
- [Data Logging IoT Weight Scale](https://learn.adafruit.com/data-logging-iot-weight-scale.md)
- [Walkmp3rson: Personal MP3 'Tape' Player](https://learn.adafruit.com/walkmp3rson-personal-mp3-tape-player.md)
- [Solder Dispenser Adabot Head](https://learn.adafruit.com/solder-dispenser-adabot-head.md)
- [Disco Band Camp Jacket](https://learn.adafruit.com/disco-band-camp-jacket.md)
- [CircuitPython Media Dial](https://learn.adafruit.com/media-dial.md)
