As an interesting exercise in learning about Arduino timing and experimenting with piezo devices, consider the following project by Dan Nicholson. He's used an Arduino to measure the occurrence and delay between vibrations from a knock, which are detected by the piezo sensor. This data is fed into an array in memory, and then used to replay the knocking duration using the speaker once more, for example:
Although it may seem like a simple and fun project, there are many uses for such a thing - for example with a little more work you can create a "knock lock" or a with some imagination perhaps a game based on remembering and repeating the sequence and duration of knocks. Either way, visit the project page for more information. And for more, we're on twitter and Google+, so follow us for news and product updates as well.
If you're interested in working with making sounds and tunes for various reasons or knock detection, we have a neat little SOUND: sound and buzzer module:
It can be used as a noise-maker driven by your microcontroller for audible feedback of events, and it can also be used as a knock-detector input to sense events and react to them. Includes a built-in 1M resistor to allow the piezo element to detect shocks. For more information and to order, please visit the product page here.