About
Active buzzers have a built-in frequency and loudness, and thus are simple to wire: they only need power and ground. You should power them with DC (not AC, as they need a constant current to produce sound). These are mainly useful for signaling or an alarm.
Getting started
const int buzzerPin = 8;
void setup() {
pinMode(buzzerPin, OUTPUT); // initialize digital pin 8 as an output
}
void loop() {
digitalWrite(buzzerPin, HIGH); // turn the buzzer on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(buzzerPin, LOW); // turn the buzzer off by making the voltage LOW
delay(1000); // wait for a second
}
Related Components