> For the complete documentation index, see [llms.txt](https://longer-vision-robot.gitbook.io/arduino-full-stack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://longer-vision-robot.gitbook.io/arduino-full-stack/05_audio_sensors/006_passivebuzzer.md).

# 5.1 Passive Buzzer

## Hardware Wiring

![Passive Buzzer](/files/-LCFEEGS87teQ636z600)

## Sketch

The code can be found at [Examples\_Arduino - sensor-kit-for-arduino - \_006\_PassiveBuzzer - \_006\_PassiveBuzzer.ino](https://github.com/LongerVisionRobot/Examples_Arduino/blob/master/sensor-kit-for-arduino/_006_PassiveBuzzer/_006_PassiveBuzzer.ino).

```
int buzzer=8; // Set buzzer IO pin, here 8
void setup()
{
  pinMode(buzzer,OUTPUT); // set buzzer pin as output
}
void loop()
{
  unsigned char i,j;  // Variable Definition
  while(1)
  {
    for(i=0;i<80;i++) // broadcast a noise at one frequency
    {
      digitalWrite(buzzer,HIGH);  // start buzzing
      delay(1); // delay 1ms
      digitalWrite(buzzer,LOW);   // stop buzzing
      delay(1); // delay 1ms
    }
    for(i=0;i<100;i++)  // broadcast a noise at the other frequency
    {
      digitalWrite(buzzer,HIGH);  // start buzzing
      delay(2); // delay 2ms
      digitalWrite(buzzer,LOW);   // stop buzzing
      delay(2); // delay 2ms
    }
  }
}
```
