KY-006 Passiv Piezo-Buzzer module
KY-006 Passiv Piezo-Buzzer module
Contents 1 Picture . 1 2 Technical data / Short description . . . . 1 3 Pinout . . . 2 4 Code example Arduino . . 2 5 Code example Raspberry Pi . . . . 3
Picture
Technical data / Short description
PWM-Signals of different frequencies can be used to create different sounds from the Piezo-Buzzer.
Export: 16. 06. 2017
Copyright by Joy-IT - Published under CC BY-NC-SA 3. 0
Page 34 of 214
KY-006 Passiv Piezo-Buzzer module
Pinout
Code example Arduino
This is an example program which will start an alarm signal on the buzzer via square wave voltage.
int buzzer = 8 ; // Declaration of the buzzer-output pin void setup () {
pinMode (buzzer, OUTPUT) ;// Initialization of the output pin. }
void loop () {
unsigned char i; while (1) {
// The buzzer will be controlled by 2 different frequencies in this program. // The signal is a square wave signal. // The on and off of the buzzer will generate a sound which is nearly the sound of the frequency. // The frequency will be defined from the time of the on and off period. //Frequency 1 for (i = 0; i <80; i++) {
digitalWrite (buzzer, HIGH) ; delay (1) ; digitalWrite (buzzer, LOW) ; delay (1) ; } //Frequency 2 for (i = 0; i <100; i++) { digitalWrite (buzzer, HIGH) ; delay (2) ; digitalWrite (buzz...