Secret knock door lock

Knock the secret rhythm on the door and the deadbolt turns for you. A wrong rhythm gets a red light and a small servo twitch, and the bolt stays shut. Both arms full of groceries and no hand free for the keys: the knock opens it.

  • 11 parts
  • 8 wiring steps
  • Arduino code
  • 5 V supply

Quick answer

The short version. Every pin is in the full wiring below.

What you need

  • Arduino Nano
  • MG995 servo
  • 27 mm piezo disc
  • 1N4733A zener diode, 5.1 V
  • 1 Mohm resistor
  • 4.7 kohm resistor
  • 220 ohm resistor, two of them, one for each LED
  • 5 mm green LED and 5 mm red LED
  • 6 mm push button
  • 1000 uF 25 V electrolytic capacitor
  • 5 V 2 A power supply

How to wire it

  1. Supply plus and minus to the breadboard power rail.
  2. Rail 5 V to the Nano's 5V pin, the servo's red lead and the plus of the 1000 uF capacitor.
  3. Every ground to the minus rail: the Nano GND, the servo's brown lead, the capacitor's stripe, the piezo's black lead and both LED cathodes.
  4. Piezo red lead to a node that also holds the 1 Mohm resistor to ground and the zener, its band on the node and its other end (anode) to ground.
  5. That same node through the 4.7 kohm resistor to A0.
  6. Servo orange lead to A1.
  7. D6 through a 220 ohm resistor to the green LED anode, and D4 through a 220 ohm resistor to the red LED anode.
  8. D2 to a top leg of the button and ground to the bottom leg on the other side.

Before you power it: All 5 V. Keep your key, pick gaps that are not obvious, and build it only on a door you own: anyone who hears the knock can copy it.

A see-through wooden door with an MG995 servo and an arm on its thumb-turn, a round piezo disc, a 1000 microfarad capacitor, a green and a red LED, a PROGRAM button, an Arduino Nano and a 5 V supply, with a fist knocking from the left
The circuit as wired in the Short. Every wire end is a real pin; the netlist was checked before the video went out.

Parts list

  • Arduino Nano
  • MG995 servo (turns the deadbolt's thumb-turn a quarter turn)
  • 27 mm piezo disc, taped inside the door to feel the knocks
  • 1N4733A zener diode, 5.1 V
  • 1 Mohm resistor (from the piezo node to ground)
  • 4.7 kohm resistor (in series with A0)
  • 220 ohm resistor, two of them, one for each LED
  • 5 mm green LED and 5 mm red LED
  • 6 mm push button (PROGRAM)
  • 1000 uF 25 V electrolytic capacitor
  • 5 V 2 A power supply, with one breadboard power rail

Wiring, step by step

  1. Supply plus and minus to the breadboard power rail.
  2. Rail 5 V to the Nano's 5V pin, the servo's red lead and the plus of the 1000 uF capacitor. Nothing goes on VIN.
  3. Every ground to the minus rail: the Nano GND, the servo's brown lead, the capacitor's stripe, the piezo's black lead and both LED cathodes.
  4. Piezo red lead to a node that also holds the 1 Mohm resistor to ground and the zener, its band on the node and its other end (anode) to ground.
  5. That same node through the 4.7 kohm resistor to A0. The zener and the 1 Mohm protect A0.
  6. Servo orange lead to A1.
  7. D6 through a 220 ohm resistor to the green LED anode, and D4 through a 220 ohm resistor to the red LED anode.
  8. D2 to a top leg of the button and ground to the bottom leg on the other side. The two legs on one side are the switch; the legs across the body are joined inside.

How it works

  1. The piezo disc turns each knock into a small voltage. The 4.7 kohm and the 5.1 V zener keep it safe for A0.
  2. The sketch notices A0 passing 60 and records the time of every knock until 400 ms of quiet ends the pattern.
  3. It compares the gaps with the rhythm it remembers: the longest gap counts as 100 and the others must match within 25, so the tempo does not matter. Five knocks are needed.
  4. On a match the green LED lights, the servo pushes the thumb-turn a quarter turn, returns to the middle and lets go, so the key still works. After a short wait it locks again.
  5. On a miss the red LED lights and the servo twitches three times. To store a new rhythm, hold the button and knock five times.

The code: knock_lock.ino

The Arduino code for this circuit is in the Wirecora Discord, in the channel #arduino-code (owner’s choice, 14 October 2026: the code lives where you can ask about it). It is a plain .ino file you can download there.

From the Short's own checked drawing; it needs only the Servo library that comes with the Arduino software. It was checked by simulation, not run on a real door. Tune HIT and the 80 ms ring-down wait to your door, and set OPEN_MS to about 4000 for a real lock.

Get the code in #arduino-code

What the video simplifies

  • The door is drawn see-through, and the electronics are drawn much larger than the door and the hand. The bar over the door shows what the sketch heard, and the knock rings are drawn.
  • The servo swings more slowly than a real one. The lock relocks after 0.8 s in the video; use about 4 s on a real door (OPEN_MS in the sketch).
  • The servo current (about 0.5 A moving, up to about 1.2 A stalled) and the piezo capacitance are typical values, not measured. The horn, link and slot on the servo are our own concept, and the sounds are synthesised.
  • This was checked by simulation and datasheets, not built.
  • Anyone who hears the knock can copy it, so this is a convenience lock, not a safe.

You found this by searching. Here's the whole path.

  1. Read how it works
  2. See it work
  3. Build it
  4. Show it
Next: see it work

Thirty seconds of video shows the circuit doing its job.

Then build it

All 5 V. Keep your key, pick gaps that are not obvious, and build it only on a door you own: anyone who hears the knock can copy it.

Then show it

Built it, or stuck halfway? Post a photo in the Wirecora Discord. Questions get an answer every day.