Introduction: Mysterious BOOK With Secret Knock Lock

About: I am an electronics hobbyist and I love to share my works with others

When it comes to hiding our secret things .we normally hides inside a bottle or in a box thats ok.!

But not ok always atleast for geeks because that is not 100% safe and also there is no interesting thinks in that so in this tutorial i am showing how i made a Book with secret knock lock. With this book we can hide your valuable things inside. no one can take anything without your knowledge because we close our book with a secret knock lock. So lets get start.

Step 1: Making Tutorial (video)

I made a video tutorial also. so watch the video to see the action.

Step 2: Features

  • Single button to program or record a new lock
  • We can hide our small things inside the book
  • No one thinks about this kind of a locker system
  • We can lock this book with special knock
  • We can use this circuit also in our door systems
  • A supersimple hobby project

Step 3: How This Works..?

I told you before this secret lock is based on knocks.

The piezoelectric disc

The main component of our circuit is a piezo disc.

Piezoelectricdisc is a transducer and which converts mechanical vibration in correcsponding with the help of arduino We reads the knock vibration. Thats all about sensing part.

Such a way we can read the knocks with help of programming we can store special sequence knocks and also drive the lock. (Programming explains in later)

Step 4: Components Needed for This

1.Arduino (any arduino)

For prototyping i used arduino uno and to decrease the size of the circuit i used arduino pro mini

2.Piezoelectric disc

Piezo is not necessary for this project we can also use Small mic or speaker. If you dont find piezo you can salvage from buzzer.

3.sg90 servo

A servo is a type of gear motor with high torque we use servo for locking purpose

4.resistors (1mega ohm,10k,1k)

5. 2* LEDs

for indicate the status use different colours board

7.Button switch

8.3.7volt battery

Small is better i am using lithium polymer

Step 5: Circuit Daigram


  • Connect piezoelectric to Analog pin 0 and ground also add 1mega ohm resistor between piezo
  • Connect servo D3
  • Connect LEDs to D4 and D5
  • Connect button switch to D2 and 5v also connect 10k pull down resistor

Step 6: Code Overview and Trouble Shooting


const int threshold = 4;This is the sensitivity of the knock detector. If you get a lot of noise, raise this (up to 1023), if you're having a hard time hearing knocks you can lower it (as low as 1)

constint rejectValue = 25;

constint averageRejectValue = 15;

Both of these are used to determine how accurately someone has to knock. They are percentages and should be in the range of 0-100. Lowering these means someone must have more precise timing, higher is more forgiving. averageRejectValue should always be lower than rejectValue.Settings of about 10 and 7 make it hard for two people to knock the same knock even if they know the rhythm. But it also increases the number of false negatives. (ie: You knock correctly and it still doesn't open.)

const int knockFadeTime = 150;This is a crude debounce timer for the knock sensor. After it hears a knock it stops listening for this many milliseconds so it doesn't count the same knock more than once. If you get a single knock counted as two then increase this timer. If it doesn't register two rapid knocks then decrease it.

const int lockTurnTime = 650;This is now many milliseconds we run the motor to unlock the door. How long this should be depends on the design of your motor and your lock. It's okay if it runs a little bit long since I've designed a simple slip clutch into the design, but it's better for all the parts if it doesn't run too much.

const int maximumKnocks = 20;How many knocks we record. 20 is a lot. You can increase this if your secret hideout is protected by devious drummers with good memories. Increase it too much and you'll run out of memory.

const int knockComplete = 1200;Also known as the maximum number of milliseconds it will wait for a knock. If it doesn't hear a knock for this long it will assume it's done and check to see if the knock is any good. Increase this if you're a slow knocker. Decrease it if you're a fast knocker and are impatient to wait 1.2 seconds for your door to unlock.about Line 39:int secretCode[maximumKnocks] = {50, 25, 25, 50, 100, 5.....This is the default knock that it recognizes when you turn it on. This is weird rhythmic notation since every value is a percentage of the longest knock. If you're having a hard time getting it to recognize "shave and a hair cut" change this to {100,100,100,0,0,0... and a simple sequence of 3 knocks will open it.



Serial.println("Program start.");Uncomment these lines to see some debug info on the serial port. There are a few other lines of debugging code set throughout the rest of code that you can uncomment to see what's going on internally.Be sure to set your serial port to the right speed.The rest of the code is commented so you can see how it works but you probably won't need to change it if you aren't changing the design.

Servo library

download code from here

Step 7: Shrinking the Circuit (soldering)

I tested the circuit on breadboard after reducing all error and after calibration i decided to shrink the circuit.

So i changed the arduino uno to arduino promini. Then i soldered all components according to circuit diagram on a dot pcb. Then with the help of single stranded wire i connected the dot pcb with promini. Thats all

Step 8: Locker Making

First i took a old dairy (thickness should be higher than servo )

Then i glued the pages together

After drying i drawn a rectangle inside and with help of scale and knife i cut and carve the paper and made it into a cavity

Watch the video for better idea.

Step 9: Lock Making and Finalization

i took the servo hand and cut into two pieces then i joined the two pieces together like a L shape

And everything fixed inside the book

I fixed the piezo on cover

And thats it....

Step 10: Drawbacks, Improvements

The major drawback of this lock is in the battery. If the battery drains completely we need to destroy the book to takeback our things.

To solve that i am planing to change the circuit with external supply with two leads ..

Step 11: Thanks

If you facing any problem on this please comment it below



Secret Compartment Challenge

Participated in the
Secret Compartment Challenge