Short version
What can cause a buzzer to produce a different sound with the exact same tone() call?
Longer version
I have a buzzer like this one:
I honestly have no idea of the exact characteristics of it, I salvaged it from something but I don't remember what.
What I do know is that it uses very little current, in the order of 3 mA compared to the 20 mA or so (depending on resistors) I get from other buzzers I have laying around... So I like it a lot.
But the thing is, it produces an inconsistent pitch and I was wondering if it's about to die or I'm doing something wrong... And since I'm completely ignorant about these things (i know there are different kinds of buzzers), I thought I'd ask.
The buzzer is connected to pin 11 on a Nano, via a 100 ohm resistor, and then ground obliviously, and the code to make it work is this:
void SonarAlarma() {
for (byte i = 1; i <= 3; i++) {
for (byte j = 1; j <= 2; j++) {
tone(PINBUZZER, 440);
delay(200);
noTone(PINBUZZER);
delay(200);
}
delay(200);
}
}
So beep-beep... beep-beep... beep-beep.
Now here's the thing. It sometimes makes a different beeping sound, one or two of those tone(PINBUZZER, 440) make a lower pitch beep.
So that's the question... what might be going on here? I really absolutely and positively would hate my life if after assembly I have to go and change the buzzer because it died.