Buzzer Tone

Browse source code on GitHub

Overview

This application plays a short attention beep followed by three tones through the buzzer device referenced by the buzzer devicetree alias, repeating once every three seconds.

The sample exercises the high-level buzzer API through buzzer_beep() and buzzer_tone(), which drive both backends:

  • pwm-buzzer for passive piezo buzzers wired to a PWM channel.

  • gpio-buzzer for active buzzers controlled by a single GPIO line. Pitch information is ignored by this backend.

Requirements

The target board must expose a buzzer device through the buzzer devicetree alias. Boards that do not have a buzzer wired in their DTS can provide an <board>.overlay file under boards/.

Building and Running

# From the root of the zephyr repository
west build -b None samples/drivers/buzzer/tone
west flash

See also

Buzzer