Driving Piezo Speakers on a PIC

Piezo speakers (also known as piezo buzzers or piezo beepers) can be directly driven from PIC outputs, in either a single-ended or differential fashion.

Single ended drive has the advantage of only needing a single output port pin. The piezo can be connected directly between the port pin and ground (or the positive supply. The port pin should be driven to the appropriate level when the piezo is idle in order to avoid applying a DC bias.

Differential drive uses two output port pins which are driven to complementary levels. This creates twice the voltage swing across the piezo, which results in higher volume. When the piezo is not being driven, both output pins should be driven to the same output level in order to avoid a DC bias.

Piezo speakers have strong peaks in their frequency response. If you are just using a piezo as a simple audible indicator, you may want to choose a frequency near a peak in order to achieve maximum volume. If a lower frequency is desirable you can use an odd submultiple of the peak fequency; since the drive is a square wave the odd harmonics (especially the third) will have fairly high amplitueds.

Rich and I have found that it is useful to include a piezo in almost any microcontroller based project during the debugging stage even if it is not needed in the finished product. In particular, if you include code to generate a beep at startup time, it provides a quick indication that power is OK, the oscillator is running, and the CPU works.

Back to my PIC Projects page
Back to my home page

Last updated September 14, 1995

Copyright 1995 Eric Smith