Interfacing KY-012(Active Buzzer) with Arduino

 Interfacing an Active Buzzer with Arduino






//Sketch-Straight beep

int active_buzzer =11;// connect the active buzzer to the pin 7 of Arduino.
void setup() {
  
pinMode(active_buzzer,OUTPUT);
}

void loop() {
  digitalWrite(active_buzzer,HIGH);
  delay(5);
  digitalWrite(active_buzzer,LOW);
  delay(1);
}


//Sketch-Alarm beep

int active_buzzer =11;// set a variable name active buzzer and assign pin to 3 

void setup() {

  

pinMode(active_buzzer,OUTPUT);// set pin as an output

}


void loop() {

  digitalWrite(active_buzzer,HIGH);

  delay(500);

  digitalWrite(active_buzzer,LOW);

  delay(5);

}

Comments

Popular posts from this blog

Proteus simulation 4x4 Matrix Keypad with Arduino and LCD screen

Digital Clock with Arduino and RTC Module and P10 LEDmatrix

Interfacing KY038 sound sensor with Raspberry pi Pico