This device consists of an active piezoelectric buzzer, compatible with Arduino, and produces a single-tone sound when the incoming signal is high.
Description:
The KY-012 active piezo buzzer is a 3-pin module that creates an audible sound at 2.5 kHz without the need for pulse width modulation (PWM) or any additional complex code. The only requirement is to set the signal pin to HIGH. If you’re looking for a simple but effective way to build audio into an Electronics or Arduino project, the KY-012 Active Buzzer Module is a great choice, and is designed to simply produce a single-tone sound when the incoming signal is high. This allows for single-pin operation on an Arduino Board, which is perfect for building a custom alarm or detection system that can send out an audible signal when it receives the electronic high signal from the Arduino controller board.
Specifications:
- Min/Max Operating Voltage +3.3V to +5V
- Maximum Current: 30mA
- Resonance Frequency: 2500Hz ± 300Hz continous
- Minimum Sound Output 85Db @ 4in (10cm)
- Storage Temperature: -22°F to 221°F (-30°C to 105°C)
- Operating Temperature: -4°F to 158°F (-20°C to 70°C)
- Dimensions: 0.73in X 0.59in (18.5mm X 15mm)
Connect signal (S) to pin 8 on the Arduino and Ground (-) to GND. Be aware that some boards are wrongly labeled, try inverting the cables if you can't hear any sound when running the sketch.
- KY-012 Module GND to Arduino GND
- KY-012 Module Signal to Arduino PIN 13
- KY-012 Module Vcc+ to No Connection
KY-012 Active Buzzer code example for Arduino:
int
GPActiveBuzzer = 13;
void
setup ()
{
pinMode (GPActiveBuzzer, OUTPUT);
// set pin to output mode
}
void
loop ()
//Main program loop
{
digitalWrite (GPActiveBuzzer, HIGH);
// sound the buzzer
delay (3000);
// pause code for 3 seconds
digitalWrite (GPActiveBuzzer, LOW);
// stop the buzzer
delay (2000);
// pause code for 2 seconds
}
KY-012 Connection Diagram for Raspberry Pi:
- KY-012 Module GND to Raspbery Pi GND
- KY-012 Module Signal to Raspberry Pi PIN 18
- KY-012 Module Vcc+ to Raspberry Pi PIN 1
KY-012 Active Buzzer code example for Arduino:
import
RPi.GPIO as GPIO
import
time
GPIO.setmode(GPIO.BCM)
# Define the output pin
GPActiveBuzzer
=
24
GPIO.setup(GPActiveBuzzer_PIN, GPIO.OUT, initial
=
GPIO.LOW)
while
True
:
GPIO.output(GPActiveBuzzer_PIN,GPIO.HIGH)
#Buzzer on
time.sleep(
4
)
#pause for 4 seconds
GPIO.output(GPActiveBuzzer_PIN,GPIO.LOW)
#Buzzer off
time.sleep(
2
)
#pause for 2 seconds