Buzzers/Speakers

Background

Active Buzzer

active_buzzer.png

The active buzzer is not a true speaker. It emits a buzzing sound at a constant frequency when a DC voltage is applied to it. There is no way to control the frequency. It can be driven by a digital output pin. They are good for an alarm-type application. You can identify the active buzzer by its entirely black underside and the fact that it comes with a sticker on the top.

 

Passive Buzzer or Piezoelectric Speaker

passive_buzzer.png

The passive buzzer is a true speaker. You can play specific tones or frequencies by passing through a pulse wave. This wave will resonate the piezo crystal and emit a sound. The pitch is determined by the frequency of the pulse.

 

Hardware Description

Pinout (same for active/passive):

 

Software Description

Active Buzzer

Can be controlled as a digital output. Write the value HIGH to turn on and LOW to turn off.

 

Passive Buzzer / Speaker

 

See the example program below. To use the note labels in any of your sketches, make a copy of the pitches.h file and include it in your project.

pitches.h: https://gist.github.com/mjdargen/a35f40af027f484eb93431876d107b47

Example Project: https://create.arduino.cc/editor/mjdargen_ravens/df9975a8-23ed-4a1b-bdfc-22a923e509a8/preview

 

Resources