Stage 3: Give It a Voice
We code the mBot in mBlock 5. Keep this tab open all week. Open in a new tab — don’t use the buttons in this page to leave the course.
a start-up beep and a short tune your mBot plays on command
how a note is a pitch and a length, and how to make a melody from a sequence
an mBot that beeps to tell you what it is doing
Before campers code, show the room:
- Play one note. Then play a higher note. Say: "A higher number is a higher sound."
- Play three notes in a row to make a tiny tune.
- Pair sound with light: beep and flash green at the same moment. Point out that a robot can use sound and light together to get your attention.
The big idea
Your mBot has a buzzer — a small speaker that plays one sound at a time. Each sound is a note. A note has two parts: a pitch (how high or low it sounds) and a length (how long it lasts). Play notes one after another, and you have a melody.
Sound is the robot's loudest way to talk to you. A beep can mean "I'm starting," "I'm done," or "I see something." You will use beeps as signals all week — they tell you what the robot is thinking even when you are not looking at it.
low note ─── high note
C4 D4 E4 F4 G4 ... (numbers go up = pitch goes up)
One buzzer, one note at a time. A melody is just notes in a sequence.
- buzzer
- the small speaker that plays sounds
- note
- one sound, with a pitch and a length
- pitch
- how high or low a sound is
- beat
- how long a note lasts
- melody
- notes played one after another
Make sure you've finished Stage 2: Light It Up. Your robot drives, glows, and is Connected.
Build it
Step 1 — One beep
The simplest sound: a single note.
Beep once
when green flag clicked play tone on note (C5) for (0.5) beats :: sound
Click the flag. One short beep.
Step 2 — Three notes make a tune
Stack notes in a sequence. Try going up the scale.
Climbing tune
when green flag clicked play tone on note (C5) for (0.5) beats :: sound play tone on note (E5) for (0.5) beats :: sound play tone on note (G5) for (0.5) beats :: sound
Run it. Three notes, climbing higher. You just wrote a melody.
Step 3 — A start-up signal
Combine sound and light into a "robot is awake" signal — the kind real robots play when they turn on.
Power-on signal
when green flag clicked set led [all v] to color [#57fff4] :: looks play tone on note (G5) for (0.25) beats :: sound play tone on note (C6) for (0.5) beats :: sound set led [all v] to color [#000000] :: looks
Run it. The robot flashes cyan and chirps two quick notes, then the light goes dark. That is your robot saying "I'm ready."
Pacing Lab
This lab is required before you move on. The goal is a signal another person can recognize, not random noise.
Part A — Compose a four-note tune (15 minutes)
On paper, plan four notes before you build them:
Note 1: ____ length ____
Note 2: ____ length ____
Note 3: ____ length ____
Note 4: ____ length ____
Build it, listen, and adjust. Changing one note's length changes the whole feel — try making the last note longer.
Part B — Name that signal (10 minutes)
Play your power-on signal for a partner alongside a different beep (like a "done" beep). Can they tell the two apart? A good signal is one you can recognize without looking.
Understand it
A melody is a sequence, the same idea you used to drive in Stage 1 — blocks running in order, one after another. The only new thing is that each block makes a sound instead of a movement. That is worth noticing: once you learn sequence, you can use it for motors, lights, or sound. One idea, many uses.
The buzzer plays only one note at a time, so timing matters. A note's length is also a tiny wait — the program pauses on that line until the note finishes. That is why you do not need separate wait blocks between notes the way you did between LED colors.
Try this
Try this
Three short experiments. Predict before you run, then test your guess.
If you change every note's length from 0.5 to 1, will the tune sound higher, lower, or just slower? Decide first, then test.
Play your tune going up the scale, then copy it and reverse the order so it goes down. Which one sounds happy, which sounds like an ending?
You can now signal with sound. In Stage 5, the robot will beep when it sees a wall. What beep would you use for "danger"? A high fast one, or a low slow one?
Test your stage
- Your robot plays a single beep on the green flag.
- Your robot plays at least three notes in a row as a melody.
- Your power-on signal pairs a sound with a light.
- Design check. Play your "ready" signal and your tune back to back. Do they sound different enough to tell apart?
If it breaks
- No sound at all. Check that mBlock says Connected and the volume of the buzzer is not set to 0. Make sure you used a note block, not a wait block.
- The notes blur together. Some notes are very short. Give each note a length of at least
0.25beats so you can hear it. - It plays once and won't replay. That is normal — click the green flag again to replay. If you want it to loop, wrap the notes in a
repeatblock.
This is the loudest stage of the week — twenty buzzers at once is a lot. Consider giving each table a turn to test, or set a "compose silently, test on my signal" rhythm so you can actually hear individual robots.
The musical kids will run far ahead here; point them at the hard stretch and the song challenge. The kids who find pitch confusing do fine with "bigger number = higher sound" — they do not need to know note names.
Tie every signal back to meaning. The point is not music for its own sake; it is that sound is a channel the robot uses to tell the human what is happening. That framing carries into the sensor stages.