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

6,188

41

24

Posted

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

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.

Code

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.

Recommendations

• Arduino Class

67,984 Enrolled

• Spotless Contest

We have a be nice policy.

Questions

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 :)

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 (https://josephmalloch.files.wordpress.com/2010/01/... 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!

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?