So first off, I'm trying to make an alarm clock that looks like the bomb from CS:GO. Everything is done except the buzzer/beeping/code part. The problem is the buzzer (Which I believe is active, but not sure since the marketing says active, but I can change the pitch) doesn't stop at the delay() command. Here's the test code I found online:
static const int buzzerPin = 13; // set the variable "buzzerPin" to pin 13
void setup(void) {
pinMode(buzzerPin, OUTPUT); // set the buzzerPin as output
}
void loop() {
beep(); // execute the "beep" function
delay(1000); // pause 5s
}
void beep() {
tone(buzzerPin, 196, 100); // give a tone on the buzzerPin, at 196hz for, 200ms
}
The tone() turns off with delay() command, but the default 2KHz tone of the buzzer continues to pierce my ears. How do I stop the default tone from playing in between beeps? Even noTone() doesn't stop the default buzzing frequency.
I've connected the buzzer to 5v, GND and pin d13 (UNO)
It says it's not a true piezoelectric buzzer and I also think so as yesterday I ran a program that played the Russian anthem to check if it can play melodies and it can. So it's not a fixed frequency buzzer. So in reality it's like a tiny speaker
"This is a small 12mm round speaker that operates around the audible 2kHz range. You can use these speakers to create simple music or user interfaces.
This is not a true piezoelectric speaker but behaves similarly. Instead of a piezoelectric crystal that vibrates with an electric current, this tiny speaker uses an electromagnet to drive a thin metal sheet. That means you need to use some form of alternating current to get sound. The good news is that this speaker is tuned to respond best with a square wave (e.g. from a microcontroller)."