Arduino Uno
Breadboard
Active Buzzer
Wires
There ative buzzers and passive buzzers. The active buzzers can be used with the function tone, which allows to play a certain sound during some time. To identify the active buzzer, check if the bottom is covered and one of the legs is bigger.
For example to play yhe note Do it can be used the following code:
After setting the tone, it is necessary to wait (using the delay function) the same time plus 1, to assure the note is played and stopped, so notes are not continuous.
To simplify the process of writing musics or sounds, you can use a file notes.h, which should be put in the same folder has the INO file. Then just include it to be able to use. See below an example, which plays the notes Do, Re, Mi.
To better understand, please view the file notes.h.
Inside the notes.h there is a function playNote, which can be used to simplify even more the process to play notes.