> 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](/files/-LCFE9bvcb1JBfofpfTF)

## 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
}
```
