How To: Forget Keys—Use a Secret Knock to Open Your Locked Boxes

Forget Keys—Use a Secret Knock to Open Your Locked Boxes

There is something special about a secret knock. It gets you into secret super villain meetings and is a surefire way to test for rotating bookcase passages. Secret knocks usually work with an intimidating drug lord and for policeman listening at the door for the correct pattern of raps.

If you want the novelty of a secret knock, but want to forgo all of the mystery and proximity to organized crime, you can make a simple Arduino knock sensor for your home, cigar box, or safe.


  • Arduino
  • Piezo buzzer
  • 1 megohm resistor
  • Servo
  • Box or door to lock

Step 1: Circuit

Our circuit consists of just an Arduino, a servo, and a piezo buzzer. If you just want the fun of knocking and receiving a response, you could write an Arduino program that uses the buzzer as both a sensor and an audio output.

Note that the 1M resistor attaches across the leads of the piezo element.

Step 2: Test

Upload this code to the Arduino and try tapping on the piezo element with your hand. You should see a response in the serial monitor. Every time you hit the piezo hard enough, the word "knock" appears in the terminal.

NOTE: I did not have a 1 megohm resistor on hand, but was able to use this modified code to get the knock sensor working.

Step 3: Install

I used a cigar box as my knock activated safe.

Image via

The lock mechanism is just a servo motor that holds the lid down when activated. Smaller servos work better for this as they take up less volume inside the box.

Image via

Cut a groove into the lid of the box as shown below. Make sure it is tall enough and wide enough to allow the servo horn to move freely.

Image via

You can use wood screws to fasten your servo to the box, but I just used hot glue.

Image via

To make sure the piezo element picks up the knock vibrations, we need to hot glue it to the inside lid. I don't know which orientation maximizes the vibration inside the element, but the positioning shown below worked fine for me.

Image via

Put your Arduino and battery inside the box and make sure all the wires are still connected. Bring the lid down and knock the box once. The servo should move away from the latch allowing you to close the lid, and then return to the closed position, locking the box closed.

Step 4: Horde

Now that you have a secret box, you need stuff to hide! Try picking up a jewelry thieving habit or type up those memoirs of your time at the CIA. Whatever you need to hide, this design can easily be modified for differently sized boxes, doors, and compartments.

What would you hide in knock box? Let us know in the comments below or post your ideas and questions in the Mad Science forum! We love to hear from you. Try making your very own knock box today!

Just updated your iPhone? You'll find new features for Podcasts, News, Books, and TV, as well as important security improvements and fresh wallpapers. Find out what's new and changed on your iPhone with the iOS 17.5 update.


This is brilliant. You're a mad genius sir.

I've a question.
How to change the knock code ?

This box opens with just one knock. Check out this door lock project for clues on code.

I want to make knock detect with face detection can u help me?!

Share Your Thoughts

  • Hot
  • Latest