> 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/010_activebuzzer.md).

# 5.2 Active Buzzer

## Hardware Wiring

![Active Buzzer](https://2341898987-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LCFDbcteyTR3tQSs-5x%2F-LCFE4dCRQBMq1ajywfh%2F-LCFE9bvcb1JBfofpfTF%2F010_activebuzzer.jpg?generation=1526059561085061\&alt=media)

## Sketch

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

```
int speakerPin = 8; // Define speaker's pin, here 8
int potPin = 4;     // Define the pin to control the adjustable resistor
int value = 0;
void setup() {
  pinMode(speakerPin, OUTPUT);
}
void loop() {
  value = analogRead(potPin); // Read the analog value of the adjustable resistor's pin
  digitalWrite(speakerPin, HIGH);
  delay(value); // adjust the buzzing time
  digitalWrite(speakerPin, LOW);
  delay(value); // adjust the NOT buzzing time
}
```
