# Attaching a Piezo Buzzer

Just like using the LEDs, we are going to get an output from the buzzer when we send an electrical current. With this small buzzer, there is no volume control. The sound is based on the quantity of electricity that is received.

If you turn the voltage on and off fast enough, you get different beeps, squeals, chirps and buzzes.&#x20;

![Turn over your Buzzer and locate the + and -](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpUPSf3tCxHePJxNjfg%2F-Lq7ozLzRMJ04uwCuEBC%2F-Lq7rXlb9aQaHiUqz_h-%2F07950-2.jpg?alt=media\&token=77d88f7c-53a9-4fb3-a934-24dc73edc63b)

#### If you flip the buzzer over and look at the bottom, you will see that one pin has a (+) next to it. That pin gets connected to a signal from the P0 pin. The other pin should be connected to ground.

![Connect your Wires](https://2507214486-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpUPSf3tCxHePJxNjfg%2F-Lq7ozLzRMJ04uwCuEBC%2F-Lq7rf5HppAquINv4pkm%2Fimage.png?alt=media\&token=9a4ea6cc-e0b3-4cae-b048-b65592dda472)

So how does this little buzzer work? I don't see an on off switch?&#x20;

```
send electricity to buzzer to make sound
stop electricty to buzzer to stop sound
```

#### &#x20;Try and make a simple sound by writing to the PIN&#x20;

```
Start
    digital write pin 0 to 1
    play tone Middle C for 2 beats
    digital write pin 0 to 0
```

Assignment:

* [ ] Turn on sound when Button A Pressed
* [ ] Turn off sound when Button B Pressed
* [ ] Play "custom" siren when A and B pressed that is no longer than 10 seconds total

