← Back to Missions
EASY • 30 MINUTES

Mission 3: Musical Robot 🎵

Make the robot play songs and create sound effects!

🎵

🎯 What You'll Learn

🎼 Sound Frequencies

How Hz (vibrations) create different musical notes

🔊 Piezo Buzzers

How speakers work by vibrating to make sound

🎹 Musical Notation

Note names (C, D, E) and their relationships

⏱️ Timing & Rhythm

Using beats and pauses to create melodies

📦 What You Need

🛠️ Let's Make Music!

1

Find the Speaker

The micro:bit has a tiny built-in speaker! On the V2 version, it's on the back near the logo. It's a small piezo buzzer that can play tones and simple melodies.

🔊 How It Works: The buzzer is a thin metal disc. When electricity pulses through it at different speeds (frequencies), it vibrates—creating sound waves we hear as notes!
2

Play Your First Note

In MakeCode, look in the Music category. Drag out a "play tone" block:

On Start:
  Play tone [Middle C] for [1 beat]

Upload it and press the reset button on the micro:bit. You should hear a single note!

🎹 Note Picker: The block has a piano keyboard! Click different keys to choose notes. Middle C is a good starting point.
3

Create a Simple Melody

Let's play a familiar tune—"Twinkle Twinkle Little Star"! Here are the notes:

On Button A Pressed:
  Play tone C for 1 beat
  Play tone C for 1 beat
  Play tone G for 1 beat
  Play tone G for 1 beat
  Play tone A for 1 beat
  Play tone A for 1 beat
  Play tone G for 2 beats
🎼 That's "Twin-kle twin-kle lit-tle star"! Each word gets one note. Try playing more of the song!
4

Use Built-In Melodies

MakeCode has pre-programmed songs! Try the "play melody" block:

On Button B Pressed:
  Play melody [Dadadum] [Once]

Explore the melody dropdown—there's "Birthday", "Power Up", "Jump Up", and more!

🎮 Game Sounds: These are perfect for adding sound effects to projects. "Power Up" when the robot starts, "Sad Trombone" when it crashes!
5

Create Sound Effects

Make the robot "talk" using frequencies! Here are fun effects:

  • 🚨 Siren: Alternate between 400Hz and 800Hz rapidly
  • 🤖 Robot Voice: Play random low tones (200-500Hz)
  • 🚀 Rocket Launch: Start at 100Hz, increase to 1000Hz
  • 💥 Explosion: Play descending random tones fast
  • 🎺 Fanfare: Quick rising notes (C-E-G)
Example - Siren:
Forever:
  Play tone 400Hz for 100ms
  Play tone 800Hz for 100ms
6

Combine Music + Movement!

Make the robot play music WHILE it drives! This is multitasking:

On Button A Pressed:
  Set Motors: Left=100, Right=100
  Play melody [Power Up] [In Background]
  Pause 2000ms
  Set Motors: Left=0, Right=0

The "In Background" option lets music play while other code runs!

🎪 Challenge: Create a "dance routine" where the robot spins and plays music!

🎼 Quick Music Theory Lesson

What is Hz (Hertz)?

Hz means "vibrations per second." When you play 440Hz, the speaker vibrates 440 times every second. Your ear hears this as the note "A". Higher numbers = higher pitch!

Common Notes & Frequencies:

  • • Middle C = 262 Hz
  • • D = 294 Hz
  • • E = 330 Hz
  • • F = 349 Hz
  • • G = 392 Hz
  • • A = 440 Hz
  • • B = 494 Hz
  • • High C = 523 Hz

Fun Fact: Dogs can hear up to 45,000 Hz! Try playing super high notes (above 15,000 Hz) and see if your pets react—you might not hear anything, but they will! 🐕

🔬 What's Happening Behind the Scenes?

The micro:bit sends electrical pulses to the piezo buzzer. When you ask for 440Hz, it switches the buzzer on and off 440 times per second. This rapid vibration pushes air molecules, creating sound waves that travel to your ears!

Real-World Connection: Synthesizers, smartphones, and computer speakers all work this way. Music production software uses frequencies and waveforms to create everything from piano sounds to electronic beats! 🎧🎹

🎨 Creative Challenges

🎹 Keyboard Robot

Button A = one note, B = another. Shake = random note. Make it a musical instrument!

🚗 Car Sounds

Forward = engine revving (rising tone), Stop = brake screech (descending), Reverse = beeping

🎼 Song Composer

Compose your own song! Write out the notes on paper first, then program it.

🎮 Game Sound Effects

Create a coin collection sound, jump sound, level complete fanfare!

Mission Success Checklist

🚀 Ready for More?

Fantastic! The boys now understand sound waves, frequencies, and musical notation. They've learned how computers generate audio—the same principles behind music production and sound design!

Keep jamming: Can they recreate their favorite video game theme song? Or design alarm sounds for different robot "moods"?

Next Mission: Line Follower 🛤️ →
← Back to All Missions