# PyRuler Video Conference Panic Buttons

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/093/647/medium800/adafruit_products_PyRuler_crop.jpg?1596304973 The four-key keyboard for the next time you have to PANIC!)

Have you ever been in a video chat, and had some kind of disaster happen that left you scrambling to mute and cut your video feed? I know I have - the most recent being when I spilled hot coffee on my lap. PANIC!

This project was inspired by [Simon Prickett's Zoom Panic Button](https://simonprickett.dev/making-a-single-button-keyboard/), which allows a user to both mute and cut video at the push of an arcade switch embedded in a Starbucks cup.

Like many of us, I'm spending a lot more time on video calls these days, but Zoom isn't the only video conferencing software I use. Most of my work meetings are on Microsoft Teams or Skype, and personal meetings are on either [Zoom](https://zoom.us/) or [Jitsi](https://github.com/jitsi/jitsi-meet).

Each one of these applications uses its own hotkeys for muting and stopping the camera, so one button wouldn't do the trick, and my desk is already littered enough with Starbucks cups, so I thought it would be best to build something new! 

As it turns out, I had a Trinket M0 *already embedded with four buttons* in the form of an [Adafruit PyRuler](https://www.adafruit.com/product/4319). Even better, it's already pre-programmed as a USB HID device, so it was ready to go as a keyboard entry device.

This is a quick and easy project that lets you program your PyRuler as a multi-application panic switch. If you have access to a 3D printer, you can also create a labeled enclosure for it for when you PANIC!

![](https://cdn-learn.adafruit.com/assets/assets/000/093/648/medium800/adafruit_products_PyRuler_Zoom.png?1596307426 How quickly can you hit both of these buttons with a lap full of hot coffee? A PyRuler can help...)

## Parts
Featured
### Adafruit PyRuler - Engineer Reference Ruler with CircuitPython

[Adafruit PyRuler - Engineer Reference Ruler with CircuitPython](https://www.adafruit.com/product/4319)
The first time you soldered up a surface mount component you may have been surprised "these are _really small_ parts!" and there's a&nbsp;dozen of different names too! QFN, TDFN, SOIC, SOP, J-Lead, what do they mean and how can you tell how big they are? Now you can have a...

In Stock
[Buy Now](https://www.adafruit.com/product/4319)
[Related Guides to the Product](https://learn.adafruit.com/products/4319/guides)
![A purple-manicured finger presses the capacitive touch pads on a purple electronic ruler. The LEDs light up as the finger presses the capacitive gold pad.](https://cdn-shop.adafruit.com/product-videos/640x480/4319-05.jpg)

Featured
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

Out of Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
![USB cable - USB A to Micro-B - 3 foot long](https://cdn-shop.adafruit.com/640x480/592-01.jpg)

# PyRuler Video Conference Panic Buttons

## Code

This project doesn't require much (any) knowledge of CircuitPython to get up and running, but if you're new to it, and would like to know more,&nbsp;[there is a full getting started guide here](https://learn.adafruit.com/welcome-to-circuitpython "Welcome to CircuitPython"). There's also a great [introduction to the PyRuler here](https://learn.adafruit.com/adafruit-pyruler/usage).  
  
If you'd like to edit the code, Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. [You can learn about Mu and installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor "Mu tutorial").

If you haven't already reprogrammed your PyRuler, it should come pre-programmed as a USB HID keyboard that you can try out. Plug the PyRuler into your computer USB port via an A to microB cable. A drive named **CIRCUITPY** should appear. Open the **code.py** file on that drive in [Mu](https://learn.adafruit.com/adafruit-circuit-playground-express/installing-mu-editor) and change this line:  
  
`ENABLE_KEYBOARD = False`  
  
to:  
  
`ENABLE_KEYBOARD = True`  
  
Then when you hit one of the four buttons, it will type Ω, µ, π, or [https://www.digikey.com/python](https://www.digikey.com/python) (I totally just typed those on my PyRuler!)

## Quick Install

Because we already have everything we need to use the PyRuler as an HID keyboard, getting up and running is very simple:&nbsp;

- Download the code as a **code.py** file
- Plug the PyRuler into the computer with a microUSB power/data cable
- Once the **CIRCUITPY** drive appears, just drag the **code.py** file you downloaded into the **CIRCUITPY** folder and replace the **code.py** file that's there
- The PyRuler should immediately reboot, and start working as a panic button for your video conferences!&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/093/675/medium800/adafruit_products_PyRuler_install.jpg?1596373481 To install, just download the new code.py file and replace the one on your PyRuler!)

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

## More Details

The code is a lightly-modified version of the code that comes on the PyRuler. However, rather than typing the keys for Ω or µ, it presses the combination of hotkeys needed to toggle the camera and microphone in that specific application.  
  
For example, the first button (the Ω) looks like this:  
  
`# Zoomkbd.press(Keycode.ALT, Keycode.V)kbd.release(Keycode.V)time.sleep(0.25)kbd.press(Keycode.A)kbd.release_all()`

In Zoom, the hotkey for for starting/stopping video is Alt-V, and the hotkey for mute/unmute is Alt-A.  
  
In the code, we're just asking it to press the Alt key, press the V key, release the V key, wait a quarter of a second, press the A key, then release all keys.  
  
"But wait!", you ask, "You didn't hit Alt before the A!"  
  
True, but for modifier keys like Alt, they affect all keys pressed&nbsp;_while holding them down_. They act just like the Shift key, which is just another modifier key. If you hold the Shift key down and START TYPING, all of your letters become capitals - you don't have to press Shift for each one.

The code for Teams looks slightly different:  
  
` kbd.press(Keycode.CONTROL, Keycode.SHIFT, Keycode.M)kbd.release(Keycode.M)time.sleep(0.5)kbd.press(Keycode.O)kbd.release_all()`

Here, we have TWO control keys, both Control and Shift before the M and O keys are pressed. (Ctrl-M is for mute/unmute, and Ctrl-O is for starting/stopping video. You can see why these are difficult to remember in all the apps!  
  
The other thing that's different here is the time between the M and O keys being pressed is increased to half a second. While testing the program, I found that some applications didn't respond very well when the keys were pressed too quickly. Sometimes, this would result in just the microphone being muted, but the video remaining on.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/676/medium800/adafruit_products_PyRuler_Muted.png?1596375268 This is a fine situation, but not if you didn't mean for it to happen!)

Even worse, as these hotkeys are toggles (they turn things both off and on), if you'd press the button on the PyRuler again, you could unmute the microphone&nbsp;_and_ turn off the video!  
  
Real-world testing is important, and sometimes small tweaks are needed in the code!

# PyRuler Video Conference Panic Buttons

## Enclosure

## Parts

The PyRuler is a little thin to sit nicely on your desk, so I designed a small 3D-printable enclosure for it. This isn't necessary for the project to function, but it makes it a bit nicer to use.  
  
The enclosure is printed in two separate parts that need to be glued together. I recommend cyanoacrylate glue (super glue).  
  
[PyRuler\_Base.stl](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/PyRuler_Video_Panic/PyRuler_Base.stl) is the base of the ruler with the labels and a groove for the cover.  
  
[PyRuler\_Cover.stl](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/PyRuler_Video_Panic/PyRuler_Cover.stl) sits in the groove on the base and holds the PyRuler in place.

The cover&nbsp; **must&nbsp;** be printed with supports. These should be easy to remove, but be sure to remove them thoroughly, or the ruler won't slide in easily. The base doesn't require any support. I recommend a layer height of .2mm, and it's a quick print (~2 hours).

![](https://cdn-learn.adafruit.com/assets/assets/000/093/678/medium800/adafruit_products_PyRuler_enclosure_parts.jpg?1596377523)

The base can be printed in two different colors by splitting the layers at 2.2mm of height and changing the filament to a contrasting color.

You can of course also print in a single color and use a marker or paint to color in the lettering.  
  
A [non-labeled version of the base](https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/master/PyRuler_Video_Panic/PyRuler_Base_Blank.stl) is also available, in case you'd prefer to make your own, or customize it!

## Assembly

Assembling the enclosure is easy, it's just two parts that need to be glued together.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/679/medium800/adafruit_products_PyRuler_enclosure_glue.jpg?1596377738)

Apply a very thin bead of the cyanoacrylate glue to the 'groove' on the base - a little goes a long way!  
  
The cover should fit into this groove easily, but shouldn't move around much if at all.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/680/medium800/adafruit_products_PyRuler_enclosure_press.jpg?1596377889 Press from the left and hold the ends open while the glue sets.)

Press the cover firmly into place, and apply pressure to the right side, while also holding the open ends on the left side open. This ensures that the ruler will slide in easily, but won't move around inside the enclosure.  
  
This glue sets very quickly, so you should only have to hold this for 30 seconds or so.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/681/medium800/adafruit_products_PyRuler_enclosure_slide.jpg?1596378020)

Then you simply slide the PyRuler all the way into the enclosure, where it will be held in place by two little bumps on the base.  
  
If you ever need to take the ruler out, you may need to use a hobby knife to shave off the bumps to slide it out.  
  
That's it! Plug it in, and now you're ready in case you PANIC!

# PyRuler Video Conference Panic Buttons

## Usage

Plug a microUSB power/data cable into the PyRuler and then into the computer. The PyRuler should be recognized as both a HID Keyboard and a drive.  
  
Once it's recognized by the computer, just press the capacitive touch sensor corresponding to your video conference application to mute the audio and stop the video. Another press should turn it back on once you've finished panicking!

![](https://cdn-learn.adafruit.com/assets/assets/000/093/795/medium800/adafruit_products_MVIMG_20200803_210045.jpg?1596506693 Just press to PANIC! (In Teams, in this case...))

A couple of usage pointers:

- Make sure your video conferencing application is in focus - it's the window that is in the foreground and you're not accidentally hitting hotkeys in other applications. This could have unexpected results!
- Hit the button that corresponds to the application you're using - hitting the wrong button could also have odd consequences.

# PyRuler Video Conference Panic Buttons

## Going Further

In the Code section, you've seen how to change the hotkeys, and learned the importance of real-world testing. There are a lot of potential improvements to this project that are worth exploring.

- Do you need to control a different application? Find the hotkeys, change the code, and try it out!
- The LEDs on the PyRuler currently light up when pressing the button. As we're toggling something, perhaps it would be better if the lights instead turned on/off with each button press?
- The buttons are capacitive sensors, and the symbols don't match the functions. Could you put some kind of covering over the buttons that still allow the touch sensors to work?
- Rather than using the touch sensors, you could always wire your own capacitive touch pads or switch. What kind of panic switch would you prefer?
- Can you design a better enclosure - maybe one that can be printed as a single piece?
- Could you use the Trinket M0 with a single big panic button and a rotary switch to change between applications?

If you make any improvements, or even just make your own version, I'd love to see it! You can always reach out to me @grajohnt on Twitter.

![](https://cdn-learn.adafruit.com/assets/assets/000/093/684/medium800/adafruit_products_PyRuler_Panic.jpg?1596379028 John / CC BY-SA (https://creativecommons.org/licenses/by-sa/2.0) Source: https://commons.wikimedia.org/wiki/File:Panic_button.jpg)


## Guide Products

### Adafruit PyRuler - Engineer Reference Ruler with CircuitPython

[Adafruit PyRuler - Engineer Reference Ruler with CircuitPython](https://www.adafruit.com/product/4319)
The first time you soldered up a surface mount component you may have been surprised "these are _really small_ parts!" and there's a&nbsp;dozen of different names too! QFN, TDFN, SOIC, SOP, J-Lead, what do they mean and how can you tell how big they are? Now you can have a...

In Stock
[Buy Now](https://www.adafruit.com/product/4319)
[Related Guides to the Product](https://learn.adafruit.com/products/4319/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

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

## Related Guides

- [Adafruit PyRuler](https://learn.adafruit.com/adafruit-pyruler.md)
- [Ping Pong Ball Launcher](https://learn.adafruit.com/ping-pong-ball-launcher-with-cpx.md)
- [ulab: Crunch Numbers fast in CircuitPython](https://learn.adafruit.com/ulab-crunch-numbers-fast-with-circuitpython.md)
- [CLUE Rock, Paper, Scissors Game using Bluetooth](https://learn.adafruit.com/rock-paper-scissors-circuitpython.md)
- [Cellular Data for CircuitPython with FONA](https://learn.adafruit.com/cellular-data-for-circuitpython-with-fona.md)
- [Lego Neon NeoPixel Sign with CircuitPython](https://learn.adafruit.com/lego-neon-sign.md)
- [Crickit Powered Dancin' Snowman!](https://learn.adafruit.com/crickit-powered-dancin-snowman.md)
- [Visual Studio Code for Education... and CircuitPython](https://learn.adafruit.com/visual-studio-code-for-education-and-circuitpython.md)
- [How to Hack NES ROMs to Add Your Own Sprites](https://learn.adafruit.com/how-to-hack-roms-to-add-your-own-sprites.md)
- [Make It Log](https://learn.adafruit.com/make-it-data-log-spreadsheet-circuit-playground.md)
- [Paper-Craft Crystal Gem Lantern](https://learn.adafruit.com/paper-craft-crystal-gem-lantern.md)
- [PyPortal Trivia Time with the Open Trivia Database](https://learn.adafruit.com/pyportal-trivia-time-open-trivia-database.md)
- [Pathfinder Robot Companion](https://learn.adafruit.com/pathfinder.md)
- [CircuitPython Powered AT Hand-Raiser](https://learn.adafruit.com/at-hand-raiser.md)
- [PyPortal LIFX Lighting Controller ](https://learn.adafruit.com/pyportal-lifx-lighting-controller.md)
- [MLX90640 Thermal Camera with Image Recording](https://learn.adafruit.com/mlx90640-thermal-image-recording.md)
