Piezo Element as Input/Output?

Ive seen many posts about using a piezo element as a knock sensor or as a speaker, but is there a way in which u can use a single piezo element as both? Ex. listening to a clap and then emitting a sound through the same piezo.
Thanks in advance.

Yes, sure piezo can work both way, the trick is a "switch" it between input and output. Probably, you should write something like:
if (knock) {
pinMode (piezoPin, Output);
tone( la-la-la );
delay( xx);
tone(stop);
pinMode (piezoPin, Input);
}
Piezo should be w/o semiconductors inside, not a buzzer, just simple passive two wires device

Magician:
Yes, sure piezo can work both way, the trick is a "switch" it between input and output. Probably, you should write something like:
if (knock) {
pinMode (piezoPin, Output);
tone( la-la-la );
delay( xx);
tone(stop);
pinMode (piezoPin, Input);
}
Piezo should be w/o semiconductors inside, not a buzzer, just simple passive two wires device

Thanks magician, but the thing is: to use piezo as output you use one of the digital pins, but to use it as input you got to use the analog input.

Hmmm, I was not thinking you are using analog input, googling couple minutes I couldn't find anything with piezo attached to digital input pin. I'm sure piezo is high voltage source, so It would works with digital pin as well, just not so sensitive as analog pin.
O'K, there is tweek around: you connect two pins together, analog and digital (look which pins work with tone command). Than you read analog as usual to listen a "knock" - digital would stay as "input" at this time and doesn't affect analog in any way. When it turn to output (digital pin) to play a tone, your analog pin doesn't care - voltage +5V no danger.
Other alternative , to make delta-sigma ADC in software with oversampling, that would increase sensitivity even more, but looks too complicated for beginners....

You can use an analogue input as a digital output, just set the pin mode right. A0 is pin 14 and so on.

Has anyone seen Wayne and Layne's "tactile metronome"? It uses PIC but does use piezo as in and out.

Worth checking out to fish for ideas.
Post your results please. I am curious to see what you are scheming!
-e