Skip to content

Latest commit

 

History

History
79 lines (65 loc) · 3.88 KB

File metadata and controls

79 lines (65 loc) · 3.88 KB

Buzzer Library for Arduino - ezBuzzer

This library is designed for a buzzer to beep or play melody without blocking other code.

ezBuzzer stands for easy buzzer, which means that the library is easy to use.

Features

  • Supports both active and passive buzzers
  • Supports active HIGH and active LOW buzzers
  • Supports beep with customizable frequency
  • Supports melody playback
  • Supports manual ON/OFF control
  • All functions are non-blocking (no delay() function)
  • Cross-platform compatible (all Arduino architectures)

Available Examples

Available Functions

  • ezBuzzer(pin, buzzerType, activeLevel) - Constructor with buzzer type and active level
  • stop() - Stop buzzer and cancel any ongoing beep/melody
  • turnON() - Turn buzzer ON continuously
  • turnOFF() - Turn buzzer OFF (same as stop)
  • beep(time) - Beep for specified duration
  • beep(time, delay) - Beep with delay before starting
  • beep(time, delay, frequency) - Beep with custom frequency (passive buzzer)
  • playMelody(melody, durations, length) - Play a melody
  • setBuzzerType(type) - Set BUZZER_TYPE_ACTIVE or BUZZER_TYPE_PASSIVE
  • setBeepFrequency(frequency) - Set default beep frequency for passive buzzer
  • getState() - Get current buzzer state
  • loop() - Must be called in loop() for non-blocking operation

Buzzer Types

  • BUZZER_TYPE_ACTIVE - Active buzzer (has internal oscillator, uses digitalWrite)
  • BUZZER_TYPE_PASSIVE - Passive buzzer (requires PWM signal, uses tone())

Active Levels

  • HIGH - Buzzer sounds when pin is HIGH (default, most common)
  • LOW - Buzzer sounds when pin is LOW (some shields like Multi-Function Shield)

Tested Hardware

Buzzer Modules:

MCU Boards:

Board Tested Notes
Arduino Uno R3 ✅ Fully supported
Arduino Uno R4 WiFi ✅ Fully supported
Arduino Uno R4 Minima ✅ Fully supported
Arduino Mega ✅ Fully supported
Arduino Giga ✅ Fully supported
DIYables STEM V3 Board ✅ Fully supported
DIYables STEM V4 IoT Board ✅ Fully supported
DIYables Compact V3.0 ATMEGA328P ✅ Fully supported
DIYables ESP32 ✅ Fully supported
DIYables ESP8266 ✅ Fully supported

How To Install the Library

References