In this tutorial you will learn how to use a buzzer with Arduino.

17

Preparation:

Connection:

Upload the following sample sketch to make the Buzzer make a beeping noise:

#define buzzer 9 //connect Buzzer to digital pin9
void setup() {                
 // initialize the digital pin9 as an output.
 pinMode(buzzer, OUTPUT);     
}

void loop() {
 digitalWrite(buzzer, HIGH);   // set the Buzzer on
 delay(500);                  // for 500ms
 digitalWrite(buzzer, LOW);   // set the Buzzer off
 delay(500);                
}

You can get more info about buzzer:https://osoyoo.com/2017/05/05/buzzer-5v-breadboard-friendlytmb12a05/