Buzzer Interfacing with Arduino Board

Piezo / Buzzer Interfacing with Arduino Board

In this article, we learn how to interface Buzzer with Arduino UNO. The buzzer is also known as a piezo buzzer. It makes sound according to the signal frequency. It can be used in a variety of alarm systems so interfacing the buzzer is important.

Components Required:

  1. Buzzer / Piezo Speaker
  2. Arduino Board
  3. Breadboard and Jump Wires
  4. 100 Ohm Resistor Optional

 

Circuit Diagram:

buzzer-board-interfacing-with-arduino

 

Steps To Follow:

  1. Open Arduino IDE.
  2. Click on File.
  3. Go to New. – A new File will open
  4. Remove the Pre-Written code.
  5. Paste the code given below:
  6. Check whether your UNO has been detected by the ID by going to Tools.
  7. Click on Port – Select the COM-Port on which Arduino UNO is detected.

 

Code:

const int buzzer = 9; //buzzer to arduino pin 9
void setup(){
  pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
}

void loop(){
  tone(buzzer, 1000); // Send 1KHz sound signal...
  delay(1000); // ...for 1 sec
  noTone(buzzer); // Stop sound...
  delay(1000); // ...for 1sec
}

 

Challenges:

(a) Play the Buzzer with a 2 Second on time & 2 Seconds off time.

(b) Play the Buzzer with a 5 Second on time & 2 Seconds off time.

(c) Fade out & Fade in the Buzzer with changing intensity.

Leave a comment