In this project, we introduce the sound functions and use them to play notes through the speaker.

The assembled CREATOR Kit has an attached speaker and audio cable, and also a set of functions that allow you to play notes, music and sound effects.

If your audio cable was removed, reattach it now:

1. Insert the Audio Cable into the audio jack on the Raspberry Pi.

2. Connect the other end of the Audio Cable to the Speaker Cable (the cable attached to the Speaker Assembly). Note: It doesn't matter which way the three-pronged Audio Cable is oriented.

With the speaker hardware connected, we can start making noise with just a few lines of code...

In this project, we're just going to use the basic functionality of the sound functions to play notes of different durations. Let's start with this code:

from rstem.sound import Note note = Note('A') note.play() note.wait()

If you run this code, you'll hear a single tone play for one second. Here's how this simple four-line program works:

- On line 1, we import the `Note()` function

- On line 2, we create an "A" `Note`, that we'll store in a new variable named `note`

- On line 3, we start to `play()` the note (by default, notes play for one second)

- On line 4, we `wait()` for the note to finish playing

If you want to change the duration of the note, you can set duration in the `play()` function, like this:

from rstem.sound import Note note = Note('A') note.play(duration=0.5) note.wait()

1. What happens if you don't `wait()` for the sound to finish playing? Why?

2. If you play two of the same notes in a row for 1 second each, does it sound the same as if you play the one note for 2 seconds?

3. Can you play a rhythm, like the "Shave and a haircut" door knock?