Description
This is a Buzzer device that you can embed into your project for audio signaling, Apply 5V to this buzzer module and you’ll be rewarded with a loud noise
Getting started with Arduino Active Buzzer Module
The following sketch shows how to switch the buzzer on and off. Arduino pin number 8 is used to control the buzzer, but any digital output pin can be used by changing the pin number at the top of the sketch.
Parts required
Arduino Connections with Active Buzzer Module
make sure (+) to +ve and (-) to GND, S to the Arduino IP pin 8
CODES
Upload the following code
#define BUZZER_PIN 8
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
// pulse the buzzer on for a short time
digitalWrite(BUZZER_PIN, HIGH);
delay(100);
digitalWrite(BUZZER_PIN, LOW);
delay(2000);
}
In the sketch the buzzer is pulsed on for a short duration (100ms) and then switched off for 2 seconds (or 2000ms). This produces a short sharp periodic beep.