Micromelon Robotics
Platform
Resources
NewsAbout UsDownload
Support
Build Your Kit

Stay in the loop

New activities, teaching guides, and product updates delivered to your inbox.

Micromelon Robotics

Australian-made educational robotics for the next generation of innovators.

contact@micromelon.com.au

Company

  • About Us
  • Privacy Policy
  • Terms and Conditions

Products

  • Micromelon Rover
  • Code Editor
  • Robot Simulator
  • Junior
  • Python Library

Support

  • Resources
  • News
  • Rover Repairs
  • Contact
  • Build Your Kit

© 2026 Micromelon Robotics Pty Ltd. All rights reserved.

ABN 56 623 302 296

← Back to Resources
ActivitiesSimulator ActivitiesBeginner

Activity: Making Music I

Coding Skills

Variables

Rover Concepts

Buzzer
Activity: Making Music I

Use the Rover’s speaker to make it play songs. Combine the world of music and robotics by going through sheet music and coding the Rover to play each note.

Rover playing notes from sheet music

Rover playing notes from sheet music

Basics of Music

When it comes to reading sheet music for this task, we use two pieces of information from each note: the tone (which note it is) and the duration (how long it’s played for).

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).

Sheet music notes, letter, octave, and duration

Sheet music notes, letter, octave, and duration

Songs can be divided into a rhythm, the constant beat the music follows. Note durations are: a whole note (semibreve) lasts 4 beats; a minim lasts 2; a crotchet lasts 1. We’ll only use semibreves, minims, and crotchets for basic songs.

We’ll use ‘Mary Had a Little Lamb’ as our example for the rest of this guide. The letters have been written below the notes, but feel free to find your own songs or write your own music.

Code

Constant: a variable that never changes while the code is running. In Python, we write these in all capitals with underscores between words.

1. Setting the Constants

Setting constants for crotchet, minim, and semibreve durations

Setting constants for crotchet, minim, and semibreve durations

Set up the framework by defining constants for each note length. A constant is a value used repeatedly throughout the code that never changes, perfect for what we need here. Since all the notes are multiples of the crotchet, you can use the diagram above and some simple multiplication to set all the constants. Also decide on an octave to use, and add a comment so you remember. For this example, we’ll use octave 4.

2. Making the Music

Using the Play Note and Delay blocks to play a single note

Using the Play Note and Delay blocks to play a single note

This part can take a while. Use the Play Note and Delay blocks to play each note individually. The Play Note block starts playing the note; the Delay block controls how long it’s played. Use the constants from the previous step to control the delay. Do this for each note in the song with the correct note lengths.

Complete Code

We’ve completed part of the example song. Try to finish the rest on your own.

Example code, partial 'Mary Had a Little Lamb'

Example code, partial 'Mary Had a Little Lamb'

Continue Learning

Activity: Making Music IIRelated resourceActivity: Making Music IIBuild on Making Music I by using lists to represent songs and loops to play them, much more efficient code.

Activity: Making Music IIIRelated resourceActivity: Making Music IIIEncode entire songs as a string and program the Rover to read the music itself, using Python lists and dictionaries.

← Return to Resources