A buzzer is a device used to produce sound. There are two types of buzzer: active and passive. In the active model, buzzer starts playing sound only if connected to a power supply, but in the passive model, we need to send a pulse from the microcontroller to play sounds.
The supply voltage of the buzzer is 3 volts, 5 volts and 12 volts.
You can download the passive buzzer datasheet here.
Passive Buzzer Module Pinout
Buzzer has 2 pins: DATA and GND but the buzzer module has an extra VCC pin.
You can see the pinout in the image below.
Interfacing Buzzer with Arduino
Step 1: Circuit
Connect the wires according to the following circuit.
Step 2: Code
Upload the following code to Arduino.
/* modified on June 5, 2018 by SURYATEJA from create.arduino.cc
You can download the StarWars song project by Buzzer through the following link.