# Passive Buzzer

The purpose of the experiment is to generate eight different sounds, each sound lasting 0.5 seconds: from Alto Do (523Hz), Re (587Hz), Mi (659Hz), Fa (698Hz), So (784Hz), La (880Hz), Si (988Hz) to Treble Do (1047Hz).

![](/files/o0v4lqGZuL1JfVzdGtV2)

### **Component Required:**

1x UNO R3

1 x Passive buzzer

1x F-M wires (Female to Male DuPont wires)

#### **Passive Buzzer:**

The working principle of passive buzzer is using PWM generating audio to make the air to vibrate. Appropriately changed as long as the vibration frequency, it can generate different sounds. For example, sending a pulse of 523Hz, it can generate Alto Do, pulse of 587Hz, it can generate midrange Re, pulse of 659Hz, it can produce midrange Mi. By the buzzer, you can play a song.

We should be careful not to use the UNO R3 board analog Write () function to generate a pulse to the buzzer, because the pulse output of analog Write () is fixed (500Hz).

![](/files/HhrFQCyVk4CzIUI2nfgJ)

### **Connection Diagram:**

![](/files/HRTm4xwbSowtvgD5sCY2)

### **Wiring schematic:**

![](/files/zdBPgGOJxkxdiQH4Kc4F)

### **Physical wiring diagram:**

![](/files/hx2jZ6noPUjpgeqgNXzb)

### **Code：**

```
void setup()
{
}
void loop()
{
  for (int i = 200; i <= 800; i++) //Increase the frequency from 200HZ to 800HZ in a loop
  {
    pinMode(8, OUTPUT);
    tone(8, i); //Output frequency on port 8 delay(5);    //This frequency is maintained for 5 milliseconds
  }
  delay(4000);  //Hold for 4 seconds at the highest frequency
  for (int i = 800; i >= 200; i--)
  {
    pinMode(8, OUTPUT); tone(8, i);
    delay(10);
  }
}
```

You can also download the code below

{% file src="/files/iN3brLgRWICUbBogwFFM" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.arduinosa.co.za/arduino-kits/basic-starter-kit/passive-buzzer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
