Harmona is a lightweight PlatformIO library for generating buzzer tones and simple melodies on the ESP32 using the hardware LEDC (PWM) peripheral.
The name Harmona is derived from harmony, reflecting its role as a small, structured sound helper. The library provides a minimal and expressive API for sound feedback patterns such as beeps, success tones, and error signals.
Harmona is designed to simplify common buzzer use cases on ESP32 projects by providing:
- A clean abstraction over ESP32’s LEDC tone generation
- Reusable sound patterns for UI and game feedback
- A predictable, blocking execution model suitable for small systems
The library intentionally remains minimal and does not attempt to be a full audio or music framework.
- ESP32 LEDC-based tone generation
- Simple frequency control
- Blocking beep helper with optional off-delay
- Built-in sound patterns:
- Start
- Success
- Failure
- Victory
- Minimal API surface
- Designed for ESP32 + Arduino framework
- ESP32 only
This library relies on ESP32-specific LEDC functions and is not portable to AVR or other MCUs without modification.
- Arduino framework for ESP32
No external libraries are required.
Add the following to your platformio.ini:
lib_deps =
https://github.com/tabah-mly/harmona.gitAlternatively, place the library in your project’s lib directory:
lib/
└── harmona/
├── include/
│ └── Oculun.h
├── src/
│ └── Oculun.cpp
#include <Harmona.h>
Harmona buzzer(19); // GPIO pin connected to buzzer
void setup() {
buzzer.begin();
}The constructor accepts the GPIO pin used for tone output. Internally, Harmona configures an LEDC channel with fixed frequency and resolution.
Plays a continuous tone at the specified frequency.
buzzer.tone(523);Parameters
| Name | Type | Description |
|---|---|---|
freq |
uint16_t |
Frequency in Hz |
Stops any currently playing tone.
buzzer.off();Plays a tone for a fixed duration, then optionally pauses.
buzzer.beep(784, 200, 50);Parameters
| Name | Type | Description |
|---|---|---|
freq |
uint16_t |
Frequency in Hz |
duration_on |
uint16_t |
Tone duration in ms (default: 200) |
duration_off |
uint16_t |
Silent delay in ms (default: 0) |
Plays a short ascending tone sequence intended for startup feedback.
buzzer.start();Plays an ascending confirmation melody.
buzzer.success();Plays a descending error tone sequence.
buzzer.failed();Plays a longer celebratory tone sequence.
buzzer.victory();- Uses a fixed LEDC channel and resolution internally
- Sound patterns are intentionally short and simple
- Execution is blocking (uses
delay) - Frequency values are specified directly in Hertz
- Designed for UI feedback, not music playback
Harmona is currently in beta. The API is stable for its current feature set, with planned extensions focused on flexibility rather than complexity.
Planned enhancements include:
- Configurable LEDC channel and resolution
- User-defined melody sequences
- Optional non-blocking playback
- Tempo-based note playback helpers
- Pattern customization hooks
This project is licensed under the MIT License.
GitHub: https://github.com/tabah-mly