---
title: "Activity: Making Music (Beginner)"
date: "2024-12-31"
categories: ["Activities", "All", "Simulator Activities"]
tags: ["Buzzer", "Beginner", "Variables"]
excerpt: "Use the Rovers speaker to make it play songs. Learn to combine the world of music and robotics by going through sheet music and coding the Rover to play each note. Activity Demonstration Basics of Music:When it comes to reading sheet mu"
featuredImage: "/images/resources/activity-making-music-beginner.jpg"
---

Use the Rovers speaker to make it play songs. Learn to combine the world of music and robotics by going through sheet music and coding the Rover to play each note.

![](/images/content/40dff0-img_1856.jpg)

Activity Demonstration

### Basics of Music:

When it comes to reading sheet music for this task, we will be using two pieces of information from each note. The tone of the note and how long the note is played.

As the image to the right shows, a note can sit on a line or a space. You may find many notes of the same letter (tone) but at a higher pitch (different octave)

![](/images/content/ba4440-notes.jpg)

Songs can be divided into a rhythm, the constant beat the music follows. Shown in the diagram to the right, we have the note durations. One whole note (semibreve) lasts for 4 beats. Next, minums last for 2, and crotchets last for 1. We’ll only use semibreves, minums, and crotchets for basic songs.

![](/images/content/d535dc-rhythm.jpg)

Below is an example of ‘Mary Had a Little Lamb’ in sheet music. The letters have already been written below the notes. This is the example we will use for the guide, but feel free to find your own songs or even write your own music!

![](/images/content/df67ce-mary-had-a-little-lamb.png)

## Code:

**Constant -** A constant is a variable that never changes when the code is run. In python, we write this in all capitals with underscores between words.

#### 1) Setting the Constants:

![](/images/content/9667be-constants.png)

Now we need to start setting up the framework in our code to make music. We’ll begin by setting constants for each of the note lengths. A constant is a value used repeatedly throughout the code that never changes, which is perfect for what we need here. As all the notes are multiples of the Crotchet, we can use the diagram above and some simple multiplication to set all the constants. We also need to decide on an octave to use, so make a comment to remember this. For this example, we’ll use octave 4.

#### 2) Making the Music:

![](/images/content/167706-note.png)

This part can take a little while, but we will use the ‘Play Note’ and the ‘Delay’ blocks to play each note individually. The ‘Play Note’ block starts playing the note on the Rover, and the ‘Delay’ block controls how long the note is played. We use the constants we made before to control how long we delay. Do this for each note in the song with the correct note lengths.

#### Complete Code:

We went through and completed part of the example song. Try to finish the rest of the song on your own:

![](/images/content/c9dfce-song.png)

### Up Next:

Ready to challenge yourself with faster ways to code music? Head on over to the intermediate or advanced ‘Making Music’ guides!

[Activity: Making Music (Intermediate)](/resources/activity-making-music-intermediate)

[Activity: Making Music (Advanced)](/resources/activity-making-music-advanced)
