Piezo

Piezoelectric disks and sensors are very useful in a wide variety or projects. They can be used as contact mics, vibration sensors, or as buzzers in devices such as cell phones or sirens. Piezoelectric sensors can be used in a variety of projects as switch inputs, in conjunction with a Transistor switch, or as analog sensors from vibration or striking.

A piezo disk with two leads can be mounted to a vibrating surface from a musical instrument or speaker to create a contact mic or acoustic pickup. The voltage produced from a guitar, for instance, is within the voltages easily amplified by a standard guitar amplifier.

Peculiarities of working with Piezoelectric disks: sometimes results in a 'bounce' effect similar to a switch.
 * Voltages swing between positive and negative.
 * Piezoelectric disks send out many spikes from a single strike - this can make it difficult to get accurate readings and

Solutions to these problems: Alternatively, a single sided Opamp such as the LM324 may be used to keep the voltage from swinging below GND.
 * A Zener diode placed in the signal chain prevents the voltage swing by keeping the signal positive.

Both of these solutions result in a loss of accuracy if using the piezo in conjunction with analog to digital converters to measure force. However, without some sort of threshold or gating in your design the piezo's bounce will prove to be very annoying.
 * The spike effect can be dealt with by creating either a Software Threshold or a Hardware Gate.

The following is some simple PIC code for those of you using the PIC's internal ADC to read a piezo disk. The threshold is arbitrary and may be adjusted for your own application. In this instance the application was a contact microphone used to read a guitar's pitch and convert it to MIDI.