# Rotary Phone Dial Keypad

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/108/821/medium800/hacks_phone_demo.jpg?1644363633)

https://youtu.be/zOU_vriJEf0

The rotary phone dial is the pinnacle of user interface for satisfying, slow number entry! Originally designed for dialing phone numbers, you can now re-purpose this beautiful piece of machinery as a USB number pad to use with your computer or mobile device.

With the KB2040 Kee Boar and a bit of CircuitPython code, you can read the mechanical dial pulses and convert them to USB HID number key messages. You can also modify the code to type letters, or go even further and make your phone send MIDI messages.

![](https://cdn-learn.adafruit.com/assets/assets/000/108/717/medium800/hacks_rotary-5208.jpg?1644019180)

Primary: 

## Parts
### Rotary Dial Phone

A model 500DM telephone or equivalent with rotary pulse dialing mechanism. Designed by Henry Dryfus, and manufactured by Western Electric, with millions of them made between 1950-1980s. You can find them in basements, attics, closets, garage sales, thrift/vintage shops, and online auctions.

Licensed models later made by ITT/Cortelco, Northern Electric/Northern Telecom, and Stromberg-Carlson will work just fine.

![hacks_rotary-5213.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/718/medium640/hacks_rotary-5213.jpg?1644021758)

### Adafruit KB2040 - RP2040 Kee Boar Driver

[Adafruit KB2040 - RP2040 Kee Boar Driver](https://www.adafruit.com/product/5302)
A wild Kee Boar appears! It’s a shiny **KB2040**! An Arduino Pro Micro-shaped board for Keebs with RP2040. (#keeblife 4 evah) A lot of folks like using Adafruit parts for their Keeb builds – but with the ItsyBitsy not being pin-compatible with the Pro Micro pinout, it...

In Stock
[Buy Now](https://www.adafruit.com/product/5302)
[Related Guides to the Product](https://learn.adafruit.com/products/5302/guides)
![Angled shot of short black microcontroller.](https://cdn-shop.adafruit.com/640x480/5302-07.jpg)

### USB DIY Connector Shell - Type A Male Plug

[USB DIY Connector Shell - Type A Male Plug](https://www.adafruit.com/product/1387)
Make your own USB connections without slicing apart a USB cable and soldering those thin wires inside. These DIY "USB shells" are available in [USB A plug](http://www.adafruit.com/products/1387), [micro B](http://www.adafruit.com/products/1390), <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1387)
[Related Guides to the Product](https://learn.adafruit.com/products/1387/guides)
![Angled shot of an assembled USB DIY Connector Shell with a Type A Male Plug. The male plug faces the camera at an angle.](https://cdn-shop.adafruit.com/640x480/1387-04.jpg)

### Part: Terminal Block
quantity: 2
4 pin Euro-style
[Terminal Block](https://www.adafruit.com/product/677)

### Silicone Cover Stranded-Core Wire - 26AWG in Various Colors

[Silicone Cover Stranded-Core Wire - 26AWG in Various Colors](https://www.adafruit.com/product/1970)
Silicone-sheathing wire is super-flexible and soft, and it's 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...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1970)
[Related Guides to the Product](https://learn.adafruit.com/products/1970/guides)
![Stranded-core wires in white, gray, black, blue, green, red, orange, and yellow.](https://cdn-shop.adafruit.com/640x480/1970-00.jpg)

### RJ11 Cable

If you want to create an unholy "telephone-to-USB" cable, you'll need some four-conductor phone wire with a typical RJ11 connector on one end.

The connector should be a 6P4C type.

![hacks_rotary-5144.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/613/medium640/hacks_rotary-5144.jpg?1644001958)

Warning: 

# Rotary Phone Dial Keypad

## 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_kb2040/)
 **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/108/852/medium800/adafruit_products_KeeBoar_boot_reset.jpg?1644515196)

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)
# Rotary Phone Dial Keypad

## Code the Rotary Dialer

Once you've finished setting up your KB2040 with CircuitPython, you can access the code and necessary libraries by downloading the Project Bundle.

To do this, click on the **&nbsp;Download Project Bundle** &nbsp;button in the window below. It will download as a zipped folder.

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

## Upload the Code and Libraries to the KB RP2040

After downloading the Project Bundle, plug your KB2040 into the computer USB port. You should see a new flash drive appear in the computer's File Explorer or Finder (depending on your operating system) called&nbsp; **CIRCUITPY**. Unzip the folder and copy the following items to the KB2040's&nbsp; **CIRCUITPY** &nbsp;drive.&nbsp;

- **lib** &nbsp;folder
- **code.py**
- **boot.py**

## boot.py

This project is a bit unique in that is uses an extra file called **boot.py** to enable a special functionality. [This page](https://learn.adafruit.com/customizing-usb-devices-in-circuitpython/circuitpy-midi-serial) has lots of great details on using the boot sequence to enable and disable USB functions.

When a USB HID keyboard is used on a mobile device, the on-screen keyboard will typically disappear. In order to bring it back, you need to unplug the HID device, which is annoying. So, we've solved this by using the phone handset switch hook as an automatic enable/disable switch!

```python
import usb_hid
import board
import digitalio

# set a pull-up
# If not pressed, the key will be at +V (due to the pull-up)
button = digitalio.DigitalInOut(board.D2)
button.pull = digitalio.Pull.UP

# Disable devices only if button is not pressed
# Phone receiver is normally open when handset is in place
if button.value:
    print("USB HID disabled")
    usb_hid.disable()
```

The **boot.py** code sets up the **D2** pin on the KB2040 as an input pull up. When the phone handset is in the cradle during reset, the board starts up with USB HID disabled. If the phone handset is out of the cradle during reset, USB HID starts as usual.

This is initiated by the use of the **D2** pin in the **code.py** as a trigger for the command `microcontroller.reset()`

# Rotary Phone Dial Keypad

## Build the Rotary Phone Keypad

## Disassembly
To open up the phone, use a flat-head screwdriver to loosen the two screw in the base. The will not need to be fully removed, just unscrewed enough to release the shell.

Lift the shell off of the phone base.

![hacks_rotary-5202.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/627/medium640/hacks_rotary-5202.jpg?1644002840)

![hacks_rotary-5203.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/628/medium640/hacks_rotary-5203.jpg?1644002848)

![hacks_rotary-5204.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/629/medium640/hacks_rotary-5204.jpg?1644002855)

![hacks_rotary-5201.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/630/medium640/hacks_rotary-5201.jpg?1644002863)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/634/medium800/hacks_rotary-5200.jpg?1644002971)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/661/medium800/hacks_schematic_rotary.jpg?1644014084)

## Dial Pulse Switch
When a number is dialed on the rotary phone, the normally-closed pulse switch is opened and closed once per number dialed as the dial governor rotates back to the stop position. Dial a '1' and one pulse is sent. Dial a '7' for seven pulses. The '0' sends ten pulses.

The interval of these pulses in the US is a 100ms period, with 60ms closed and 40ms open. This can vary with phones from other countries.

https://youtu.be/3o936reAlFI

Loosen the two screws holding the dial assembly to the mounting arms. Then, gently pull the dial free from the base, being careful not to pull on any wiring.

Use a multimeter to check the wiring -- one pair is connected to the speaker disconnect switch (which prevents the dialing pulse sounds from being heard in the earpiece), the other is connected to the pulse switch.

The blue pair on this dial is the pulse switch. Loosen the two screws on the network block and remove the blue wires -- you'll later connect them to the KB2040 to read the pulses.

![hacks_rotary-5214.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/638/medium640/hacks_rotary-5214.jpg?1644005510)

![hacks_rotary-5215.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/637/medium640/hacks_rotary-5215.jpg?1644005488)

![hacks_rotary-5060.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/644/medium640/hacks_rotary-5060.jpg?1644010868)

## Receiver Switch Hook
You'll use the receiver switch hook to enable or disable USB HID. This way, when the phone is hung up the virtual keyboard on a mobile device will be available, and when the phone receiver is picked up the dial will work as a number entry device.

Using a multimeter, determine which terminals of the network block are opened and closed by the switch hook. You'll run a wire from each of these terminal positions to the KB2040 later.

![hacks_rotary-5224.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/645/medium640/hacks_rotary-5224.jpg?1644012141)

![hacks_rotary-5225b.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/646/medium640/hacks_rotary-5225b.jpg?1644012148)

## Optional RJ11-to-USB Cable Build

The simple thing to do is run a regular USB-C cable to the KB2040, snaking it through a gap in the phone shell. HOWEVER! You aren't here for simple, you're here for EXTRA. So to be totally extra, you're going to build a custom RJ11-to-USB cable, and then hijack the phone's RJ11 jack to run the wiring to the Kee Boar.

## Cable Build

Cut one end off of your phone cable (make sure it is a four conductor RJ11 cable). A three foot length should work well (the stubby piece in the photo here is for illustration purposes only!)

Carefully remove the outer cable insulation, then strip and tin each of the four wires.

Solder the cable ends into the DIY USB-A plug in the order shown here.

![hacks_rotary-5145.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/669/medium640/hacks_rotary-5145.jpg?1644015018)

![hacks_rotary-5151.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/673/medium640/hacks_rotary-5151.jpg?1644015418)

![hacks_rotary-5152.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/682/medium640/hacks_rotary-5152.jpg?1644017452)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/681/medium800/hacks_fritz_rotary_cable.jpg?1644017437)

## USB Jack Wiring
In order to run the USB-to-RJ11 cable into the phone's RJ11 jack, you'll unscrew the three terminal screws connecting the yellow, green, and red wires from the network block. These will be connected to the KB2040, along with an added black wire, in case your phone's original jack didn't contain a fourth conductor. Different phones may have different numbers, colors, and positions of jack wires.

![hacks_rotary-5066.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/663/medium640/hacks_rotary-5066.jpg?1644014309)

![hacks_rotary-5178.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/664/medium640/hacks_rotary-5178.jpg?1644014357)

![hacks_rotary-5074.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/665/medium640/hacks_rotary-5074.jpg?1644014484)

Wire colors and positions can vary, so it's important to use the continuity checker on your multimeter to connect the USB conductors to their associated pads on the KB2040.

These connections are:

- **Vcc** to **RAW**
- **GND** to **GND**
- **D-** to **D-**
- **D+** to **D+**

## KB2040 Wiring
![](https://cdn-learn.adafruit.com/assets/assets/000/108/685/medium800/hacks_rotary-5180.jpg?1644018173)

Use terminal blocks (either a barrier block as shown here or [Two Euro-style connector blocks](https://www.adafruit.com/product/677)) to run the phone wiring to the KB2040. Solder short lengths of wire to the KB2040 to make the connections.

The connections are shown on the Fritzing diagram above.

![hacks_rotary-5182.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/689/medium640/hacks_rotary-5182.jpg?1644018196)

![hacks_rotary-5181.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/690/medium640/hacks_rotary-5181.jpg?1644018206)

![hacks_rotary-5177.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/691/medium640/hacks_rotary-5177.jpg?1644018218)

### Terminal block - 4 pin Euro-Style

[Terminal block - 4 pin Euro-Style](https://www.adafruit.com/product/677)
Connect this to that **without soldering** using these quick terminal blocks. They allow connecting of two sets of four wires together using just a flat-head screwdriver. These are UL rated to carry up to 15 Amps, so they're great for high current LED strips! Can be used with wires from...

In Stock
[Buy Now](https://www.adafruit.com/product/677)
[Related Guides to the Product](https://learn.adafruit.com/products/677/guides)
![Euro-Style Terminal block with 4 pins ](https://cdn-shop.adafruit.com/640x480/677-02.jpg)

## Kee Boar Attachment

Use insulating Kapton tape or another material (I used adhesive felt) to protect the back of the Kee Boar from shorts.

Use a pair of zip ties to secure the Kee Boar to the base of the phone, making sure the terminal block and wiring is clear of any moving parts.

![hacks_rotary-5186.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/692/medium640/hacks_rotary-5186.jpg?1644018350)

![hacks_rotary-5191.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/693/medium640/hacks_rotary-5191.jpg?1644018369)

## Re-Assembly
Place the dial assembly back into it's brackets and tighten the two screws.

Tuck any wires out of the way, then place the shell back on, making sure the jacks are secured against the housing.

Re-tighten the bottom screws and you're ready to go!

![hacks_rotary-5192.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/694/medium640/hacks_rotary-5192.jpg?1644018387)

![hacks_rotary-5193.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/695/medium640/hacks_rotary-5193.jpg?1644018396)

![hacks_rotary-5201.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/696/medium640/hacks_rotary-5201.jpg?1644018415)

![hacks_rotary-5202.jpg](https://cdn-learn.adafruit.com/assets/assets/000/108/697/medium640/hacks_rotary-5202.jpg?1644018423)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/698/medium800/hacks_rotary-5207.jpg?1644018536)

# Rotary Phone Dial Keypad

## Use the Rotary Phone Keypad

https://youtu.be/vTkK8_GPRcU

Plug the USB cable into your computer or mobile device. With the receiver handset in the cradle it will not show up as a USB HID device.

![](https://cdn-learn.adafruit.com/assets/assets/000/108/711/medium800/hacks_rotary-5207.jpg?1644018965)

Lift the receiver. The board will restart, this time with USB HID enabled, thanks to the **boot.py** file code. On a mobile device such as the iPad, this will cause the virtual keyboard to disappear, indicating that the device is ready to receive "keyboard" input.

![](https://cdn-learn.adafruit.com/assets/assets/000/108/712/medium800/hacks_rotary-5208.jpg?1644019059)

Dial numbers on the rotary dial, and they will be sent to the device over USB!

![](https://cdn-learn.adafruit.com/assets/assets/000/108/714/medium800/hacks_rotary-5210.jpg?1644019117)

![](https://cdn-learn.adafruit.com/assets/assets/000/108/715/medium800/hacks_rotary-5211.jpg?1644019125)

Hang up the phone when you're done to resume virtual key entry.

![](https://cdn-learn.adafruit.com/assets/assets/000/108/716/medium800/hacks_rotary-5213.jpg?1644019151)


## Featured Products

### Adafruit KB2040 - RP2040 Kee Boar Driver

[Adafruit KB2040 - RP2040 Kee Boar Driver](https://www.adafruit.com/product/5302)
A wild Kee Boar appears! It’s a shiny **KB2040**! An Arduino Pro Micro-shaped board for Keebs with RP2040. (#keeblife 4 evah) A lot of folks like using Adafruit parts for their Keeb builds – but with the ItsyBitsy not being pin-compatible with the Pro Micro pinout, it...

In Stock
[Buy Now](https://www.adafruit.com/product/5302)
[Related Guides to the Product](https://learn.adafruit.com/products/5302/guides)
### USB DIY Connector Shell - Type A Male Plug

[USB DIY Connector Shell - Type A Male Plug](https://www.adafruit.com/product/1387)
Make your own USB connections without slicing apart a USB cable and soldering those thin wires inside. These DIY "USB shells" are available in [USB A plug](http://www.adafruit.com/products/1387), [micro B](http://www.adafruit.com/products/1390), <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1387)
[Related Guides to the Product](https://learn.adafruit.com/products/1387/guides)
### Terminal block - 4 pin Euro-Style

[Terminal block - 4 pin Euro-Style](https://www.adafruit.com/product/677)
Connect this to that **without soldering** using these quick terminal blocks. They allow connecting of two sets of four wires together using just a flat-head screwdriver. These are UL rated to carry up to 15 Amps, so they're great for high current LED strips! Can be used with wires from...

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

## Related Guides

- [Adafruit KB2040](https://learn.adafruit.com/adafruit-kb2040.md)
- [Arcade Fightstick](https://learn.adafruit.com/arcade-fightstick.md)
- [Commodore Keyboard to USB HID with CircuitPython](https://learn.adafruit.com/commodore-keyboard-to-usb-hid-with-circuitpython.md)
- [May Pad Macropad with the KB2040, KMK, and CircuitPython](https://learn.adafruit.com/maypad-macropad-with-the-kb2040-kmk-and-circuitpython.md)
- [Cyber Cat MIDI Keyboard](https://learn.adafruit.com/midi-cyber-cat-keyboard.md)
- [4x12 Ortho Mechanical Keyboard](https://learn.adafruit.com/4x12-ortho-mechanical-keyboard.md)
- [Planetary Gear Dreidels](https://learn.adafruit.com/planetary-gear-dreidels.md)
- [DOOM Keeb](https://learn.adafruit.com/doom-keeb.md)
- [Fisher-Price USB Foot Pedal](https://learn.adafruit.com/fisher-price-usb-foot-pedal.md)
- [USB MIDI Keyset Controller](https://learn.adafruit.com/midi-keyset.md)
- [See N Say Brain Transplant](https://learn.adafruit.com/see-n-say-brain-transplant.md)
- [Fisher-Price USB Controller](https://learn.adafruit.com/fisher-price-usb-controller.md)
- [Big Key Switches Macro Pad](https://learn.adafruit.com/big-key-switch.md)
- [16-Step Drum Sequencer](https://learn.adafruit.com/16-step-drum-sequencer.md)
- [Navi10 MacroPad with KB2040 and KMK CircuitPython keyboard firmware](https://learn.adafruit.com/navi10-macropad-with-kb2040-and-kmk-circuitpython-keyboard-firmware.md)
