Knock Box (it Opens When You Knock on It!)





Introduction: Knock Box (it Opens When You Knock on It!)

About: Born in Naples, Italy, lover of everything concerning about technology. Currently studying Automation Engineer at Federico II University of Naples.

Hi! This is my first Instructable. Let's start!

The idea was to create a box that opens if you knock on it with the correct rhythm. It may not be so useful, but it is a great chance to learn further Arduino and create something awesome, having the right to say: "I made it!".
Above you can see some sketches I made to figure out how the box will look. However, don't take the layout too seriously: in the final version it is different. But they are still useful to understand the "user interface".

Analyze the main image.
First of all, the switch (1): there is no much to say.
Secondly, three LEDs: when turned on, the red one (2) means that the box is locked. As you can easily imagine, the green one (3) means it is open. The last, blue LED turn on when the user knocks on the box. In this way, he/she knows if the box detected the input or not.
Then, the box provides three buttons. The first one (6) closes the box, the second one (7) plays the rhythm saved, and the third one (8) record a new rhythm.

Warning: due to technical reason, if you record a new rhythm it stays until you turn the box off. However, you can easily fix that saving the rhythm in the Arduino EEPROM (reference).

In the next step, I will show you how to realize the electrical circuit.

Step 1: Circuit and Code

This is how the finished circuit works:

Let's do it!

Things we need:
     - a piezo element;
     - a servo motor;
     - a 100uF capacitor;
     - three LEDs (red, green, blue);
     - three push buttons;
     - three 220Ω resistors, three 10kΩ resistors and one 1MΩ resistor.
You can find everything in the Arduino Starter Kit.

The circuit
Recreate the electrical circuit. The scheme is the one in the main image.
I have insterted also some pictures of the completed circuit.

You can download the code from here.

Step 2: Finally, the Box!

It's time to create the physical box. Take one big enough to contain Arduino (or the chip, if you want to create a stand alone) and the other components. I bought a wood one for about €2.50.

Pay attention: the box's lid must not be totally straight, but it needs a vertical component, as mine does. The animated gif shows how the locking system works.

Make three holes for LEDs, three for push buttons and one for the switch. See the pictures.
Now, make another hole on the, and then smooth the area next to it inside the box, so the servo's flap has enough space to move. The servo motor will move in there and prevent the box from opening.
While making holes, try to be more precise than me. It was the first time I had a drill in my hands.

Finally, insert Arduino (or chip) and components inside the box. Fix the piezo sensor at the centre of the lid and the servo motor in correspondence of the last hole.

Congratulations, your KnockBox is ready to take care of your secrets!



    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest
    • Oil Contest

      Oil Contest

    24 Discussions

    Hello sir, ive made your project and it was working well. But i only have one problem, every time i pressed the button to register new pattern, it automatically knocks by itself. It knocks 10 times straight. Hoping for your fast reply! :) Thankyou.

    Sir how is the position of the servo in the box, so that it can open? And what if i only have a piezo sensor, how can i add a buzzer? Many thanks for your reply :)

    3 replies

    Hi! For the piezo, it is just fine, you can use the sensor as a buzzer too. I glued the servo in the box, and a piece of metal with a hole in it, on the top. In this way, when the servo moves, the white end goes into the hole, closing the box.

    Anyway, I made another version of this box, using a capacitive sensor instead of a piezo (you can just use a piece of aluminium paper, attaching a wire to it). If you can do it - it only requires a few changes in the code - it's a lot more efficient sensing the user's touches!

    How can i use the sensor as a buzzer too?

    Thank you for the fast reply. I think ill be sticking on using piezo sensor, im still not good at making codes.
    The piezo sensor i saw is ( like this? It doesnt have buzzer right? hehe
    And about the servo, i still dont get it. I dont know what's the use of the hole in the picture for the servo. Sorry its my first time to use arduino and servo, to make something like this.

    Hello sir, nice circuit. What piezo have you use? Piezo buzzer or piezo sensor? Thankyou!


    1 year ago

    Tuixte, that is a great idea and i was making the circuit and when the time to upload the code to the arduino came what was my surprise, i cant download the code, can you upload the code again please?
    ---Sorry for the bad english

    1 reply

    Hi, thank you! I just tried to open the link in the instructable, and it worked for me.

    It's this one:

    Maybe you have some connection issues?

    Let me know if you have other problems.

    Hi mknyawi, just take the code from the link and put it into a .ino file.

    yeah but I think this one wouldn't work with arduino, there are commands that arent familiar with arduino. Thanks a lot for the rest though, it's an awesome project!

    I tested it and it works! :D Which commands are you referring to, by the way?

    Thank you, I'm really glad you like it!

    I changed it to .ino and it compiled fine thanks! I have an important question though, I am using a buzzer but I tested it separately and it's not reading any analog values so I will order a piezo element from the link you posted. Do you think that would be the issue? Also, do I need the 1Mohm resistor with the piezo element or is it fine without it? I don't have it.

    It could be, but make it sure to test it correctly before buying a new one, maybe it was just a broken wire. Anyway, the resistor is important, without it you'll get value too high and difficult to handle

    Hi marcus, are you sure you downloaded and installed Servo library correctly?

    Is there any chance you could post a breadboard layout for this. I'm new to all this, but would really like to have a go at this as it's just what I need for a project that I have in mind, but at the moment I struggle with the circuit diagrams.

    Many thanks

    1 reply

    Here ( you can find a picture of my breadboard layout, but I have to tell you that I really needed to make it as fast as possible, so it can be difficult to understand: moreover, some pieces (like servo and leds) are completely fixed into the box. Sorry I cannot help you better :)