Requirements:
I wanted the knock sensor to be more sensitive, so that a modest tap would register;
It should be battery operated (battery inside the box);
It should have a failsafe mode of entry in case you forget the knock or the battery dies;
When you record a new knock, it should remember it even when turned off.
I found ideas for improving the piezo's sensitivity to a knock here:
http://interface.khm.de/index.php/lab/e ... o-element/
I first ran the output of the piezo through an op amp. This helped, but I still couldn't find a good balance between sensitivity to gentle taps and over-sensitivity (when one knock gets read as two.)
I then epoxied a 25 gram fishing weight to a few different piezos. I thought that gluing the piezo directly to the surface might damp out its vibration faster and make it less likely to read multiple knocks from a single tap. For comparison, I also tried a mount similar to the one described in the above setup. By prying the back off of a Radio Shack 273-073 piezo buzzer, I had a piezo that could vibrate independently from the surface it was mounted to. I compared all three setups as shown below:
All three mountings improved the sensitivity, but the one that is not rigidly attached to the knock surface is by far the best. (Just like the web site above suggested.) When that output was fed to the non-inverting input of an op amp with just 2 x gain, there was excellent sensitivity and no mistaking one knock for two.
I included a battery testing circuit so that the LEDs flash to warn of low batteries (so you don't get locked out of the box) and I also have a secret method to jumpstart the box in case the batteries do die, or you forget the code. Here's the secret
Finally, I store the secret code in EEPROM instead of SRAM so that it is retained even when the Arduino is turned off.
Here are pictures of the final setup and a link to a video of it working:
http://www.youtube.com/watch?v=fwCppXGV ... Jy6yLElPeo
Thanks to all of the users on this forum who helped answer my questions and debug my circuit!
Sean

