Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
BuzzerXCR
BuzzerXCR is an advanced Arduino library for controlling passive buzzers with extended sound effects, PWM-based volume control, and built-in LED feedback support. Designed for alarms, games, sound indicators, and musical effects, it provides a rich set of features for sound manipulation.
Features
Easy-to-use API for passive buzzers
Volume control via PWM (optional)
LED feedback support (optional)
Sound effects:
Melody playback from arrays
Serial Terminal interaction with commands (e.g.,
BEEP
,FREQ 440
,STOP
)Debug output support for development
Installation
.zip
Example Usage
Function Overview
begin(int pausePercent)
Sets the pause percentage between notes.
end(int ms)
Delays for
ms
milliseconds at the end of a melody.sound(int note, int duration)
Plays a tone of given frequency (
note
) and duration (ms).fadeIn(int note, int duration)
Starts sound from low volume and increases gradually.
fadeOut(int note, int duration)
Starts at full volume and decreases to silence.
distortion(int fromNote, int toNote, DistortionSpeed speed)
Creates a sweeping tone between two notes with chosen speed (
SLOW
,NORMAL
,FAST
).glissando(int fromNote, int toNote, int totalDuration)
Smooth pitch slide between notes.
playMelody(const int* notes, const int* durations, int count)
Plays an array of notes with corresponding durations.
vibratePattern(const int* pattern, int count)
Plays a series of short tones and pauses, simulating vibration.
scheduleNote(int note, int duration, int delayMs)
Schedules a note to play after a specified delay.
setVolume(int percent)
Sets the buzzer volume (0–100%) using PWM.
enablePWMVolume(bool enable)
Turns on or off PWM-based volume control.
setToneCurve(String curveType)
Sets tone shaping method (e.g.,
"linear"
).debugMode(bool enable)
Prints debug messages over Serial when enabled.
serialControl(char delimiter)
Reads Serial commands like
BEEP
,FREQ 440
,STOP
.toString()
Returns a string representation of the current BuzzerXCR object state.
Serial Commands (in loop)
BEEP
- short beepFREQ 440
- plays 440 Hz toneSTOP
- stops current tone