# Buzzer - Circuit Set-up


Follow the diagram below to set up a circuit for the buzzer and button.


`````{tab-set}
:sync-group: micro
````{tab-item} Pico Wiring Diagram
:sync: pico
```{image} images/Buzzer_wiring.png
:class: bg-primary mb-1
:width: 700px
:align: center
```
````


````{tab-item} Arduino Wiring Diagram
:sync: ard
```{image} images/Buzzer_wiring_ard.png
:class: bg-primary mb-1
:width: 450px
:align: center
```
````
`````
`````{tab-set}
:sync-group: micro
````{tab-item} Pico Circuit Diagram
:sync: pico
```{image} images/Buzzer_circuit.png
:class: bg-primary mb-1
:width: 700px
:align: center
```

*Note: The LED's bent pin in the diagram represents the positive (longer) pin*
````

````{tab-item} Arduino Circuit Diagram
:sync: ard
```{image} images/Buzzer_circuit_ard.png
:class: bg-primary mb-1
:width: 500px
:align: center
```
````
`````

There is nothing new going on here. We have the same arrangement as for the [LED with button](buttonLEDlabel) except the buzzer can handle more current and does not need a resistor.

## Duty Cycle vs Frequency

For buzzers compared to LEDs, we have two parameters to consider that can change sound outputs, _frequency_ and _duty cycle_.

In terms of the signal:

- _Duty cycle_ is the % of each cycle/period in which the signal is high vs low.
  
- _Frequency_ is the number of cycles/periods per second.

In terms of sound, the difference is:

- _Duty cycle_ affects the loudness of the buzzer and is measured as a %. Lower values will yield quieter outputs.

- _Frequency_ affects the pitch of the buzzer and is measured in Hz. Lower values will yield lower pitched notes while higher values will yield higher pitches.

<br>

`````{grid}
````{grid-item}
```{image} images/PWM_crop.jpg
:width: 300px
:align: center
```
````
````{grid-item}
To understand the difference between the two we can again consider the same figure:

These different signals all have different **duty cycles** but have the same period (shown by the green vertical lines) and thus the same **frequency**.

In order to change the frequency, we would change the the period of each signal. In the diagram, to increase the _frequency_ we would squeeze the lines closer together while to decrease the _frequency_ we would widen them apart. Doing this would not affect the duty cycle since the % high vs low remains the same.
````
`````



