Knock on this coffin to awake the dead. Don’t worry, the skeleton won’t get out and come after you but it will reply from inside.
Ok, we know that you know that there isn’t a real skeleton there. It’s really a piezo used as a knock sensor. After you’ve made this project you might think of a handy way to use this sensor in other ways. Check out this secret knock detecting lock for some inspiration.
Materials
- 1 Arduino Uno board
- 1 Basic Education shield
- 2 Piezos
- 1 1M ohm resistor
- 3 colored jumper wires
- 3 black jumper wires
- 1 9v battery
- 1 9v battery holder
- Knock-knock box kit
- Masking tape
- 1 breadboard
Instructions
Code
You can find the code in File -> Examples -> Castilla -> Magic -> KnockKnockBox
How it works
The first time you knock on the box, the recording begins. Each time the knock sensor is knocked, Arduino will record the time of this occurrence into an array. If you stop knocking for more than 2 seconds, it’ll be considered as end of recording. At this stage, the pattern of knocking will be played back through the piezo speaker.
Troubleshooting
- Make sure the battery is connected properly so the power LED on Arduino is on. Test with Arduino connected to the computer and 9v battery disconnected. If it works with the USB cable but not with the battery, there could be something wrong with the battery, change for another one.
- Remember to knock on the right wall of the box (the one with piezo knock sensor).
- See piezo knock sensor reference for debugging.
Experiment further
- Change the sound of how the box knocks back.