Buzzer Module

This is a active buzzer so its easy in use. You just apply voltage to the buzzer and it makes sound. Disadvantage is that you can’t determine the frequency of the sounds, for this you need a passive buzzer.

Schematic

Module pin - = GND Module pin S = +5V

Connection to Arduino

  • Arduino digital pin 8 –> Module pin S
  • Arduino GND –> Module pin -

Example code

//Example code KY012 active buzzer
int speakerPin = 8;
void setup () {
    pinMode (speakerPin, OUTPUT);
}

void loop () {
    analogWrite (speakerPin, 255);
    delay (50);
    analogWrite (speakerPin, 0);
    delay (10);
}