QRD: Quantum Rotary Dial, Part 3

Arduino Nano programming

Guidomax wrote this sketch for the Arduino in his instructables: https://www.instructables.com/Interface-a-rotary-phone-dial-to-an-Arduino/

int needToPrint = 0;
int count;
int in = 2;
int lastState = LOW;
int trueState = LOW;
long lastStateChangeTime = 0;
int cleared = 0;

// constants

int dialHasFinishedRotatingAfterMs = 100;
int debounceDelay = 10;

void setup()
pinMode(in, INPUT);

void loop()
int reading = digitalRead(in);

if ((millis() - lastStateChangeTime) > dialHasFinishedRotatingAfterMs) {
// the dial isn't being dialed, or has just finished being dialed.
if (needToPrint) {
// if it's only just finished being dialed, we need to send the number down the serial
// line and reset the count. We mod the count by 10 because '0' will send 10 pulses.
Serial.print(count % 10, DEC);
needToPrint = 0;
count = 0;
cleared = 0;

if (reading != lastState) {
lastStateChangeTime = millis();
if ((millis() - lastStateChangeTime) > debounceDelay) {
// debounce - this happens once it's stablized
if (reading != trueState) {
// this means that the switch has either just gone from closed->open or vice versa.
trueState = reading;
if (trueState == HIGH) {
// increment the count of pulses if it's gone high.
needToPrint = 1; // we'll need to print this number (once the dial has finished rotating)
lastState = reading;

It worked perfectly for me. I ran this command from the terminal to confirm the Arduino was sending signals.

screen /dev/cu.usbserial-AM00GQIK 9600

You will probably have to change the serial port (/dev/cu.usb…) but the baud rate (9600) should be good.

Once everything was wired up and the Arduino was programmed, I was ready to move onto the python script! This script would listen to the serial port and react to the dialed in numbers.

Python programming

This was the bulk of work I needed to do. I didn’t want a rotary dial which only set the volume. I wanted it to be a working number pad. I wanted to be able to type with it. I wanted it to trigger Alfred workflows. I wanted it to type common phrases I use a lot (not passwords!)

Since the script would interpret the rotary dial’s input differently depending on the mode it was in, I also wanted this script to provide some basic UI to let the user know the active mode. The rotary phone didn’t have any lights (and I didn’t want to add any) so I opted to create a little statusbar app.

The code is available here: https://github.com/Nathancooke7/quantum_rotary_dial

The README covers how to use the dial and the various features I’ve implemented.


This was a really fun project! I got to work on my soldering skills a bit. I learned about programming Arduinos. I learned the basics of GUI.

I’m using the rotary phone to trigger Alfred workflows which message a Slack channel to let people know I’ve signed in/out of work or gone on my lunch break. I literally dial in every morning.

I hope I’ve inspired you to pursue a side project, especially this specific one. I’d love to hear how people are using QRD to improve their lives.

QRD: Quantum Rotary Dial, part 2

With my research phase complete, I had a clear understanding of components to buy and how they’d go together. Huge thanks to CameronCoward for his instructables post: https://www.instructables.com/Vintage-Rotary-Phone-Dial-PC-Volume-Control/

It’s a rather simple system:

  1. As the rotary dial spins, it will open and close a circuit.
  2. This opening and closing changes the voltage of a circuit.
  3. The Arduino Nano interprets the change in voltage (high/low) to count the “clicks” of the rotary dial and send a number over to the serial port.
  4. A python script on the computer will listen to this serial port, accepting the numbers and doing something with them.

The hardest part for me was removing the dial. A number of screws had rusted. A little WD-40 helped. In one case, the screw head was stripped and I had to use a hacksaw to cut a new slot for the screw driver.

Once everything was apart, I also removed components I didn’t need. There was a plastic box that everything wired into. Removing that created plenty of room for the breadboard circuit.

If you are interested in building this for yourself, I highly suggest you read through Cameron’s post as well as Guidomax’s instructables: https://www.instructables.com/Interface-a-rotary-phone-dial-to-an-Arduino/

Below is the circuit diagram from Guidomax:

Next: Programming

QRD: Quantum Rotary Dial, Part 1 – A Quarantine Project

As with many other people around the world, I’ve been self-isolating for the past decade. Or at least, it feels that long. I decided to put this extra time to good use by pursuing projects and passions I would have otherwise only dreamt about.

I wanted a project which would involve hardware and software; would push me to learn new skills and technologies; and would be fun. After all, this is meant to be an enjoyable experience.

I got the idea it’d be pretty cool to repurpose a rotary dial telephone to be an input device for my computer. So, I came up with a game plan:

  1. Research
  2. Build
  3. Program

Research Phase

In this phase I wanted to answer the following questions:

  1. How much are rotary dial phones?
  2. Has this been done before? If so, how did they do it?
  3. What are the components I’d need?

Finding the phone

The first question took priority because I didn’t want to spend an astronomical amount on what’s essentially a toy. I didn’t have a clear use-case for the end product. This was more about the journey, or the learning experience, than anything else.

A quick glance at ebay revealed a wide range of prices for rotary phones. I could find something reasonable for me.

I settled on a vintage 1970s ITT Model 500 Series in chocolate brown, as seen in the picture above.

On the shoulders of Giants

I’m a firm believer that we should build on the knowledge of others. Often times, we’re not the first person to encounter the problem and, with any luck, a solution might already exist.

A few evenings of internet searching revealed a number of interesting projects on rotary dial telephones.

rotaryX: A Question and Answer Machine

Link: https://www.instructables.com/RotaryX-How-to-Hack-a-Rotary-Phone/

This project is awesome. It gives you full control over every aspect of the phone: dial, hook, ringer, and receiver.

It’s also much bigger in scope than I’d originally planned. I really only wanted to use the rotary dial part.

Rotary Contoller Dials in PC Volume

Link: https://hackaday.com/2020/06/04/rotary-controller-dials-in-pc-volume/

Sometimes, the stars align. I’d started researching on June 5, 2020. This article was published on June 4, 2020. This project was extremely close to what I’d envisioned. I wasn’t going to remove the dial from the phone and print new case, but I was confident that the components would fit inside the original housing.

Within the article is a link to the Instructables by Cameron Coward: https://www.instructables.com/Vintage-Rotary-Phone-Dial-PC-Volume-Control/

It was everything I needed to get started. I was ready to start building

Purchasing Parts

Thanks to Cameron’s instructables post, I knew I needed the following:

  1. A rotary phone
  2. Arduino Nano
  3. Resistors (470 ohm and 10k ohm)
  4. Solderable bread board

The resistors and bread board were nominal cost. The phone was $20 (plus shipping and tax) and the Arduino cost me $17. So in total, this project cost about $50.

Next: Build Phase

Set working directory

I’ll often be working in a directory over multiple days. To easily get to that directory I set up an alias in my bash profile like this

alias repo=’cd /path/to/directory’

But I found it tedious having to change the alias and reload the profile whenever I started working on a new project.

So, I wrote this quick little script was changes the alias and updates my bash profile for me.

Hope you find it useful.



Today’s post is about one leg of the CIA Triad, Integrity, which means protecting data from unauthorized modification. There are a number of things needed to ensure data integrity, but let’s focus on detection. More specifically, let’s focus on detecting changes to files.

Detecting changes

The easiest way to detect if a file has been changed is to hash it and compare that to a previous hash of the file. Hashing algorithms will detect small changes in files to produce very different outputs. For example, this is the SHA256 hash of Allen Ginsberg’s Howl:


and this is the SHA256 hash of Allen Ginsberg’s Howl with an extra space at the end:


So, having a hash of a file will allow you to quickly determine if it’s been modified. For this reason, hashing is frequently used in File Integrity Monitoring solutions.

Of course, your choice in hashing algorithm matters. A number of security issues have been discovered with the hashing algorithm MD5; a quick search can give you more details. TL;DR don’t use MD5 for integrity checking, use SHA256.

Use Case

You can use it to ensure the integrity of import documents and files. For instance, when submitting an Incident Response Report, you should always add an additional document providing hashes of every file included with the report. This way, it will be easy to detect if the report or supporting documents have been modified.

Here’s a little script I wrote to quickly hash all files in a directory and create a csv



# directory from command line to recursively hash
if [ -z "$1" ]; then
  echo "supply directory with files to hash"
# input must end in / so the awk command later will function properly.
elif [[ $1 = *"/" ]]; then 

# get basename of directory to name output file
SAVETO=$(basename $DIR)

# write CSV header
echo "File, SHA256" > hashed_$SAVETO.csv

# find all files in directory and:
#   hash it if the file is NOT DS_Store
#   print filename and its hash to file
find $DIR -type f -print0 | xargs -0 openssl sha256 | awk -F \/\/ '$2 !~ /DS_Store/ {print $2}' | awk -F \= '{match($1,"\\)")}{OFS=","}{print substr($1, 0, RSTART-1), $2}' >> hashed_$SAVETO.csv

echo "hashes saved to hashed_$SAVETO.csv"

Just include the directory of files as a command line argument and you’re good to go!

Keeping Track of How Tos

Working at a start-up, I get to wear many hats and gain experience in a wide-range of topics.

But that also means picking up a project, learning skills needed to complete it, then moving on to the next project which may not require any of the knowledge I just acquired. For example, as part of an Incident Response project last year, I needed to determine how easily a password hash could be cracked. So, I learned how to use John the Ripper and about hash cracking in general. After concluding that project, I moved onto the next thing. It wasn’t until the next incident a year later that I needed to use John the Ripper again.

Then there are those random questions you never want to waste time figuring out again. Like, “How do I remove newline characters from within quoted text in this csv so that awk sees the quoted text as one field?”

This quick succession and breadth of topics meant that I’d often have to recall something from a few months ago.

So, how do I prevent having to relearn something I knew last week/month/year?

How Tos! lots and lots of How Tos. So many How Tos that managing them became an issue. But that’s a good problem to have, and one I solved with a simple little bash script.


With this script from my repo, you can list, search by topic, open, edit, and create new HowTos.

Using the help option will explain what the Topic Tags mean. Then you can make a new HowTo using the new option. Once you’ve written a couple HowTos you’ll be able to find them easily by searching with the Topic Tag, though sometimes I’ll just list them all out and pipe through grep.

There’s also a batch of Howtos in my repo to help get you started.

It’s made my work much easier having a quick way to parse through my notes and HowTos. I hope it helps you.