• Arduino
  • Raspberry Pi
  • Raspberry Pi Pico
  • Micro:Bit

When this sensor is powered, this active buzzer generates a sound with the frequency of 2.5 kHz. The active buzzer module, unlike the passive module KY-006 does not require a square wave voltage to generate a tone. If a voltage of min. 3.3 V is applied to its signal pin, the required square wave voltage is generated by the buzzer itself.

Technical data

Operating voltage 3,3 V - 5 V
Maximum current 30 mA
Tone frequency 2,5kHz ± 300 Hz
Minimum sound output 85 dB
Operating temperature -20 °C - 70 °C
Storage temperature -30 °C - 105 °C
Dimensions 19 x 15,5 x 11 mm

Pin assignment

Code example Arduino

Pin assignment Arduino

Arduino Sensor
Pin 13 Signal
- +V
GND GND

This code example shows how the buzzer can be switched on alternately for four seconds and then switched off for two seconds using a definable output pin.

int Buzzer = 13;
 
void setup ()
{
  pinMode (Buzzer, OUTPUT); // Initialize output pin for the buzzer
}
 
void loop () //main program loop
{
  digitalWrite (Buzzer, HIGH); // Buzzer is switched on
  delay (4000); // wait mode for 4 seconds
  digitalWrite (Buzzer, LOW); // Buzzer is switched off
  delay (2000); // Wait mode for another two seconds in which the LED is then turned off
}

Example program download

KY012-Arduino-ON-OFF

When this sensor is powered, this active buzzer generates a sound with the frequency of 2.5 kHz. The active buzzer module, unlike the passive module KY-006 does not require a square wave voltage to generate a tone. If a voltage of min. 3.3 V is applied to its signal pin, the required square wave voltage is generated by the buzzer itself.

Technical data

Operating voltage 3,3 V - 5 V
Maximum current 30 mA
Tone frequency 2,5kHz ± 300 Hz
Minimum sound output 85 dB
Operating temperature -20 °C - 70 °C
Storage temperature -30 °C - 105 °C
Dimensions 19 x 15,5 x 11 mm

Pin assignment

Code example Raspberry Pi

Pin assignment Raspberry Pi

Raspberry Pi Sensor
GPIO 24 [Pin 18] Signal
- +V
GND [Pin 6] GND

This code example shows how the buzzer can be switched on alternately for four seconds and then switched off for two seconds using a definable output pin.

# Required modules are imported and set up
import RPi.GPIO as GPIO
import time
  
GPIO.setmode(GPIO.BCM)
  
# Here the input pin is declared, to which the sensor is connected.
Buzzer_PIN = 24
GPIO.setup(Buzzer_PIN, GPIO.OUT, initial= GPIO.LOW)
  
print("Buzzer test [press CTRL+C to exit test]")
 
# main program loop
try:
    while True:
        print("Buzzer 4 seconds on")
        GPIO.output(Buzzer_PIN,GPIO.HIGH) #buzzer is switched on
        time.sleep(4)#wait mode for 4 seconds
        print("Buzzer 2 seconds off")
        GPIO.output(Buzzer_PIN,GPIO.LOW) #buzzer is switched off
        time.sleep(2)#wait mode for another two seconds then LED is off
  
#rearrange after the program has been terminated
except KeyboardInterrupt:
    GPIO.cleanup()

Example program download

KY012-RPi-ON-OFF

To start with the command:

sudo python3 KY012-RPi.py

When this sensor is powered, this active buzzer generates a sound with the frequency of 2.5 kHz. The active buzzer module, unlike the passive module KY-006 does not require a square wave voltage to generate a tone. If a voltage of min. 3.3 V is applied to its signal pin, the required square wave voltage is generated by the buzzer itself.

Technical data

Operating voltage 3,3 V - 5 V
Maximum current 30 mA
Tone frequency 2,5kHz ± 300 Hz
Minimum sound output 85 dB
Operating temperature -20 °C - 70 °C
Storage temperature -30 °C - 105 °C
Dimensions 19 x 15,5 x 11 mm

Pin assignment

Code example Micro:Bit

Pinout Micro:Bit:

Micro:Bit Sensor
Pin 1 Signal
- +V
GND GND

This is an example program which switches the buzzer ON or OFF.

When this sensor is powered, this active buzzer generates a sound with the frequency of 2.5 kHz. The active buzzer module, unlike the passive module KY-006 does not require a square wave voltage to generate a tone. If a voltage of min. 3.3 V is applied to its signal pin, the required square wave voltage is generated by the buzzer itself.

Technical data

Operating voltage 3,3 V - 5 V
Maximum current 30 mA
Tone frequency 2,5kHz ± 300 Hz
Minimum sound output 85 dB
Operating temperature -20 °C - 70 °C
Storage temperature -30 °C - 105 °C
Dimensions 19 x 15,5 x 11 mm

Pin assignment

Code example Raspberry Pi Pico

Pin assignment Raspberry Pi Pico

Raspberry Pi Pico Sensor
GPIO18 Signal
- +V
GND GND

This code example shows how the buzzer can be alternately switched on for three seconds and then switched off using a definable output pin.

# Load libraries
from machine import Pin
from utime import sleep

# Initialization of GPIO18 as output
device = Pin(18, Pin.OUT, value=0)

# Switch on buzzer
print("ON")
device.on()

# Wait 3 seconds
print(".")
sleep(1)
print(".")
sleep(1)
print(".")
sleep(1)

# Switch off buzzer
print("OFF")
device.off()

Example program download

KY012-Pico-ON-OFF