RaspberrySTEM comes with an attached speaker and audio cable, and also a library of functions that allow you to play notes, music and sound effects.
The hardware required to use the speaker is assembled as part of the kit assembly, so we can start making noise with just some lines of code...
In this project, we're just going to use the basic functionality of the sound library to play notes in variable durations. Let's start with this code:
If you run this code, you'll hear a single tone play for one second. If you want to change the duration of the note, you can set duration in the play() function, as you see below: