I am looking to use the ezBuzzer library Reference page Here. Git Hub page here for a project, just a beeper playback basically. I am finding that it doesn't always play the low notes, when they are played as a medium to short duration.
They can play fine, but when set to similar values as in the example I share here, you can hear that some are missed.
I was wondering if anyone knows what is is about the library that allows this to happen, and do you know if there is something I could do to stop it from missing notes?
/*
Created by ArduinoGetStarted.com
This example code is in the public domain
Tutorial page: https://arduinogetstarted.com/library/arduino-melody-repeat-example
Library References: https://arduinogetstarted.com/tutorials/arduino-buzzer-library
This example uses a piezo buzzer:
+ play a melody on background
+ repeat the melody when it is ended
+ without using delay() function, this is a non-blocking example
*/
#include <ezBuzzer.h> // ezBuzzer library
const int BUZZER_PIN = 3;
ezBuzzer buzzer(BUZZER_PIN); // create ezBuzzer object that attach to a pin;
// notes in the melody:
int melody[] = {
NOTE_E1, NOTE_E1, NOTE_E1,
NOTE_E1, NOTE_E1, NOTE_E1,
NOTE_E1, NOTE_G1, NOTE_C1, NOTE_D1,
NOTE_E1,
NOTE_F1, NOTE_F1, NOTE_F1, NOTE_F1,
NOTE_F1, NOTE_E1, NOTE_E1, NOTE_E1, NOTE_E1,
NOTE_E1, NOTE_D1, NOTE_D1, NOTE_E1,
NOTE_D1, NOTE_G1
};
// note durations: 4 = quarter note, 8 = eighth note, etc, also called tempo:
int noteDurations[] = {
10, 10, 10,
10, 10, 10,
10, 10, 10, 10,
10,
10, 10, 10, 10,
10, 10, 10, 10, 10,
10, 10, 10, 10,
10, 10
};
int noteLength;
void setup() {
Serial.begin(9600);
noteLength = sizeof(noteDurations) / sizeof(int);
}
void loop() {
buzzer.loop(); // MUST call the buzzer.loop() function in loop()
if (buzzer.getState() == BUZZER_IDLE) { // if stopped
buzzer.playMelody(melody, noteDurations, noteLength); // playing
}
}
This code is just an amended version of the supplied example of Melody Repeat usage. Notes are missed and not even consistently, some may be missed and maybe not upon the next repeat.