
01 · Brief
The Rotary Dial Safe is a lockbox I built for each of my kids. Instead of a keypad, you enter the unlock code with the dial from an old telephone.
To open it, you flip the power switch, turn the key, and dial in your PIN. Get it right and the LED flashes green and the maglock pops open. Get it wrong and it flashes red and nothing happens. The PIN is set in the code.
The first version was a cardboard craft box. This one is a PLA box I designed in Fusion 360, with a cutout for the power cord so the battery can charge from a wall adapter. It is a fun personal safe and I look forward to building more things with retro tech.
02 · System
03 · Source
workingphonelock.ino
#include <Bounce2.h>
#include <TM1637Display.h>
const byte dialPin = 4; // Red wire from dial
const byte numberPin = 5; // Yellow wire from dial, blue wire from dial to GND
const byte hookPin = 2;
const unsigned long debounceDelay = 5;
const unsigned long maxPulseInterval = 1000;
const int maxNumDigitsInPhoneNumber = 4;
const byte displayClockPin = A0;
const byte displayDataPin = A1;
const byte ledPin = 7;
const byte relayPin = 8;
char number[maxNumDigitsInPhoneNumber + 1];
int currentDigit = 0;
int pulseCount;
// Create 7seg display object, (Clock pin, Data pin)
TM1637Display display(displayClockPin, displayDataPin);
// lock box states
typedef enum { Idle, Dialtone, Dialling, Connected, Invalid } stateType;
stateType state = Idle;
//bounce to catch pulses
Bounce numberSwitch = Bounce();
Bounce dialSwitch = Bounce();
Bounce hookSwitch = Bounce();
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(dialPin, INPUT_PULLUP);
pinMode(numberPin, INPUT_PULLUP);
pinMode(hookPin, INPUT_PULLUP);
pinMode(relayPin, OUTPUT);
numberSwitch.attach(numberPin);
numberSwitch.interval(5);
dialSwitch.attach(dialPin);
dialSwitch.interval(5);
hookSwitch.attach(hookPin);
hookSwitch.interval(5);
display.setBrightness(0x0c);
digitalWrite(ledPin,LOW);
digitalWrite(relayPin, LOW);
}04 · Lessons
This was good practice for managing state within code.
Using a multimeter to investigate the rotary dial and work out its wiring was fun.