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.
- 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)
- 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_TYPE_ACTIVE - Active buzzer (has internal oscillator, uses digitalWrite)
- BUZZER_TYPE_PASSIVE - Passive buzzer (requires PWM signal, uses tone())
- HIGH - Buzzer sounds when pin is HIGH (default, most common)
- LOW - Buzzer sounds when pin is LOW (some shields like Multi-Function Shield)
Buzzer Modules:
- 3V-24V Active Piezoelectric Buzzer
- Active Piezo Buzzer Module
- Passive Piezo Buzzer Module
- Multi-Function Shield for Arduino - Built-in active LOW buzzer
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 |