Active and passive buzzer modules: KY-006 and KY-012 with Arduino
A buzzer module emits a sound to signal a danger or the end of a set time. It also serves to confirm a command. There are two types: passive, such as the KY-006 and Ks0019, and active, such as the KY-012 and Ks0018. AdriRobot tested them with an Arduino UNO, with a Multi Test Shield and with the micro:bit board.
Active and passive buzzer module: the difference

The buzzer is an audio signalling device. It can be mechanical, electromechanical or piezoelectric. In the active module there is an internal oscillator: you just power it and the sound starts. The passive module has none, so the control circuit must supply it with a square wave between 2 and 5 kHz.
The piezoelectric buzzer is based on a ceramic disc with a metallic layer. It is robust and cheap. That is why it is used for narrow-band alarm signals, for example in household appliances and in medical technology. Electromagnetic buzzers, on the other hand, have a metal diaphragm set vibrating by an electromagnetic circuit, with the electronics already integrated.
The four modules compared
The KY-006 and KY-012 have the same circuit, made up of a connector and the buzzer. Only the type of buzzer changes, passive in the first and active in the second. Of the connector only GND and signal are used, so the current comes from the Arduino pin. Each module also measures 15 × 19 × 9 mm and weighs 2.4 g.
The Keyestudio Ks0018 (active) and Ks0019 (passive) modules are more elaborate. An NPN S8050 transistor acts as a switch between the control pin and the buzzer. There are two resistors: one on the base and one in series with the power supply. This way the control pin only supplies the current for the transistor. The connector therefore has three connections: GND, signal and 3.3 or 5 V power. Finally, these modules measure 30 × 20 × 10 mm and weigh 3 g.

Testing with Arduino: square wave and tone()

To test a passive module you need an Arduino UNO, some Dupont jumpers and the KY-006 or the Ks0019. In the first sketch digital pin 3 goes from high to low with short pauses. This way the square wave is built by hand. Alternatively you use tone(pin, frequency, duration), which generates a square wave with a 50% duty cycle.
The command also produces only one tone at a time. If another pin is already playing, the call has no effect, while on the same pin it changes the frequency. To stop the sound you use noTone(pin). In AdriRobot’s example the buzzer sounds at 500 Hz and at 1000 Hz for one second each. Then it stays silent for five seconds.
The active module is simpler. With the KY-012 or Ks0018 a signal pin at high level makes the buzzer sound. At low level it stops it.
Multi Test Shield and micro:bit
The Multi Test Shield is a shield built by AdriRobot, compatible with the Arduino UNO R3. It is used to test the sensors of the 37-in-1 kit. The KY-012 is inserted on the JP2 connector. This way the sketch alternates sound and silence and shows the various phases on a small OLED display.
The Ks0018 and Ks0019 modules can also be connected to a micro:bit board. You need the Keyestudio Micro:bit Sensor V2 shield and three female-female Dupont cables. The program is also written with the MakeCode block editor and saved directly onto the board.
Where to find the modules
The individual modules are in the catalogue: the passive buzzer module KY-006 and the active buzzer module KY-012. Both are also part of the box of 37 sensors for Arduino, Raspberry Pi and robotics.
Source: the original article by AdriRobot includes the complete sketches, the MakeCode programs and other examples of buzzer use in projects.
Related products
- Passive Buzzer Module, 3.5V to 5.5V Operating Voltage
- Active Buzzer Module with 3.5V to 5.5V Operating Voltage
- Box of 37 sensors for Arduino/Raspberry Pi/robotics
The post Active and passive buzzer modules: KY-006 and KY-012 with Arduino appeared first on Open Electronics.
[original story: Open Electronics]