Arduino tone()
function
The Arduino tone()
function generates a square wave of the specified frequency on a pin, which can be used to emit a tone.
Use tone()
to Play a Melody
The following code was adapted from the Play a Melody using the tone() function Built-In Example tutorial.
Broader Topics Related to Arduino tone() Function

Arduino Programming
Knowledge about programming Arduino boards