Make some noise with passive buzzer 🔊

Updated: May 5, 2020



Know it

The passive buzzer gives out sound when signal is given to the component. Use it as an alarm for your Arduino security system or just to annoy people!


Wire it

This is one of the simplest circuit! All you need is:

  • Jumper wires

  • Passive Buzer

  • Arduino board and USB cable



















Connections:

  • Arduino pin GND → Buzzer black wire

  • Arduino pin 9 → Buzzer red wire


Code it

This code allows you to control the buzzer to give a beeping sound for each 1 second. Controlling the frequency in the code, will allow the control the sharpness of the buzzer beeps.


Try it out! Copy the code bellow:


/*      
Making Beeps with passive buzzer   

Tutorial link: https://www.learn.voltaat.com/post/buzzer

This is an Arduino sketch that reads the measures distance using ultrasonic sensor, and displays it on the Serial Monitor.

Components Needed:   
1. Ultrasonic Sensor HC-SR04 .....x1     

Connections:   
- Arduino pin GND → Buzzer black wire (GND)
- Arduino pin 9 → Buzzer red wire (input)
*/

int buzzerPin = 9; // connect the red wire of the buzzer to pin 9
 
// Controlling the frequency in the code, will allow the control the sharpness of the buzzer beeps.
int Frequency = 1000  // 1KHz sound signal


// This routine run once at the start
void setup(){
  pinMode(buzzer, OUTPUT); // Set buzzer - pin 9 as an output
}

void loop(){
 
  tone(buzzer, Frequency); // Beep at 1 kHz frequency
  delay(1000);        // delay for 1 sec
  noTone(buzzer);     // Stop Beeping
  delay(1000);        // delay of 1 sec
  
}