PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Sensors expedition

Mission 2 of 6

Sensors expedition: Mission 2 of 6

Ultrasonic Drum


Beginner

1 hour

Grades 3 - 8

MISSION OBJECTIVE

Learn how to play the Distance Sensor as an instrument.

Piperbot and Pip need help soothing Baby Zomar to sleep. Play your Distance Sensor as an instrument to help. Ask students: “How does your instrument know when and what sound to play? How does an electric keyboard know how to make a sound?”

View student interface at make.playpiper.com
MISSION CHARACTERS

Piperbot

Pip

Baby Zomar
MISSION MATERIALS

Computer with USB port and Chrome or Edge browser
Piper Make Base Station or Starter Kit
Distance Sensor

MISSION RESOURCES

Learning Goals

  1. Students will use the distance measured by your Distance Sensor to play different notes like an instrument (particularly like a drum!).
  2. Students will understand how to use variables, loops, and conditionals to convert distances to different notes using list mapping.
  3. Students will understand how the Distance Sensor measures distance using sound waves that bounce off objects.
I WILL BE ABLE TO...
  • Understand how an ultrasonic sensors measure distance
  • Use code to associate distance to different sounds
  • Combine movement, sensors, and sound into an interactive system

Learning Activities

ELA Extension: Robot Miscommunication Comic

  • Pair students together or allow them to work independently based on writing level and creativity. Students will write a narrative that uses sensory detail, rhythm, and cause-and-effect to bring their robot drum to life in a story setting.
  • Begin by creating the scene. Ask: Where is the robot drum? What sets it off—sound, movement, or something unexpected?
    Examples: A talent show, a space concert, or a thunderstorm where the drum warns someone.
  • Build suspense or celebration by describing how the drum reacts. Use sound-based rhythm language like: “Boom! Boom! Pause. Tap-tap!”
  • Have students write their story in first- or third-person voice, describing how the robot affected the mood, helped a character, or became the center of attention. Encourage use of cause-and-effect and emotional reactions to drive the plot.
  • Students then trade stories with a peer for feedback on pacing, detail, and creativity. Revise based on input before final sharing.

Bonus vocabulary words to include: ultrasonic, sensor, distance, trigger, output, frequency, pattern

EXTENSION: Invite students to write a sound poem or spoken-word piece inspired by their robot drum’s rhythm and scene.



ELD Extension: Robot Drum Reaction Practice
  • Pair students so that each English Learner (EL) is working with a fluent or higher-level EL. Students will practice using rhythmic cues and sentence frames to describe motion-triggered sounds.
  • Begin with Vocabulary & Visuals. Introduce words using images or real-life props:
  • drum, sound, sensor, hand, move, beat, loud, soft
  • Practice commands and phrases with body movement:
    • “Wave your hand closer.”
    • “Move your hand far away.”
    • “The drum plays a sound when I ___.”
  • In pairs, students play a Reaction Game: One student moves their hand toward or away from an imaginary sensor. The other describes the result using sentence starters:
    • “When my hand is close, the drum goes ___.”
    • “When I move away, it ___.”
  • Wrap up with a Class Performance. Students act out short skits in which the robot drum responds to someone entering a room, dancing, or making a speech. End with a reflection, using visuals or sentence frames to describe what happened.

Math Extension: Distance vs. Drum Beat Data
  • Pair students together or allow them to work in groups based on grade level and measurement readiness. Students will measure how distance affects rhythm in the ultrasonic drum and represent results with data and logic.
  • Begin by testing how the drum responds at different distances. Example ranges: 0–5 cm, 6–10 cm, 11–15 cm, etc. Record how many beats happen at each range or describe the speed of rhythm.
  • Have students organize their data in a chart with these columns:
    • Distance range
    • Sound type (fast, medium, slow)
    • Beats in 10 seconds
  • Graph the results using a bar or line graph to visualize the relationship.
  • Prompt students to reflect:
    • “What happens as your hand gets closer?”
    • “What’s the relationship between distance and drum behavior?”

EXTENSION: Create Your Own Pattern
Students write custom if/then logic statements to describe how the drum should behave.

Examples:
  • “If distance < 5 cm, play 3 fast beats.”
  • “If distance > 15 cm, stay silent.”

Career Connections

Robotics Engineer: Salary $104,600/yr
Automotive Engineer: Salary $95,300/yr
Civil Engineer: Salary $88,050/yr
Electro-Mechanical and Mechtronics Technicians: Salary $60,570/yr

Hardware Diagram




Code Diagram




Tutorial Steps

Ultrasonic Drum

It's your moment to unleash your inner drummer! In this tutorial, we're going to use your ultrasonic range finder to define different sounds at different distance ranges measured.

Ready? Let's do it!

You'll need to snag your ultrasonic range finder and the diode jumper cables for this tutorial.
Click NEXT.

Let's start by connecting up our Ultrasonic Range Finder to your Raspberry Pi Pico.

The colors of the wires on your 4-pin cable can vary, so it is important to match the pins on your sensor module to the correct connections on your Breadboard.

Remember, the DIGITAL VIEW is a handy way to see the GPIO pin locations. For this circuit, you will connect:
  • GND to G (ground)
  • SIG to GP22
  • VCC to 5V
You will leave NC disconnected. Follow this guide and use the wiring diagram below:

Start by dragging out a start block from the Chip Menu. Then, grab a repeat forever block from the Loops menu and connect it to the start block. Change the wait time on the start block to 0.25 seconds.

Then let's define a variable called distance sense to measure the distance from the range finder.

Since the range finder is connected to pin 22, use a range finder block from the Sensing menu for the range finder to measure the distance in cm.
Click NEXT.

Since our range finder detects best within 300 cm, we want to our drum to apply to distances measured within 300 cm. Drag out an if _ = _ do block from the Logic menu and connect it below the set distance sense block. Change the = to a <.

Drag a distance sense value from the Variables menu and place it into the first input of the _ < _ block. Then, Drag a 0 from the Values menu and place it into the second input of the _ < _ block. Change the 0 to 300.
If the distance is less than 300 cm, then we're going to play a sound so drag a play sound block out from the Sounds menu too. We'll define what sounds in to play in the next steps.
Click NEXT.

But what note do we want to play? If we just put one sound in the play sound block, then it wouldn't be much of a drum right?

Let's create a new variable for the note that is going to be played. We can call it "note to play". Make this variable by click the Create variable... button in the Variables menu to do this. But what will that note be?

Drag out a set note to play block and place it right before the play sound block.

Let's map the distance measured to different notes! To do this, we have to create two ranges, one of the distances that can be measured and one of the notes that can be played.

Drag out a map value block from the Logic menu and place it into the input of the set note to play block:
Click NEXT.

Let's talk a little about the mapping because that's how we're going to figure out which note gets played!

Since the distances range between 0 and 300, change the second number in the map value block from 50 to 300.

Next delete the last two number value blocks in the map value block. Grab a note block from the Values menu and place it into one of the empty inputs at the end of the map value block. Do it again for the other input.

We want to use the distance sense variable, so grab a distance sense block from the Variables menu and place it into the first input on the map value block.

Change the note blocks to notes between A5 and A2. This will break up the 300 cm into equal units that match the number of intervals between A5 and A2:
Grab the instrument block from the Sounds menu and place it into the input of the play sound block. Delete the note block inside of the play sound block. Grab a note to play block from the Variables menu and place it into the pitch input of the instrument block.
That's it! Click NEXT to customize it.

Now what sound would we like to create?

Change the instrument to whatever you would like! How fast do you want your notes to go? Change the length of the notes to mess with that, too!
Click NEXT.

Drumroll please... Let's test it out!

Move your hand closer and further from the sensor and see what happens! Does the sound change? Change around your parameters to see what other patterns you can create!

Click EXIT to return to the menu and start your next coding challenge.

Blueprint

OPEN IN BLUEPRINT VIEWER  DOWNLOAD

Have an different version? Look for more information on the Support Page.

Troubleshooting Tips

  • Is the Range Finder not measuring distance?
    • Pay extra attention to the wiring diagram for this one.
    • Verify all your electrical connections, including that your Pico is connected to your computer.
    • It is common for the connections to be off by 1 or 2 holes. We recommend going through each build to ensure the connections are correct.
    • Don’t worry! One of the wires (NC) does not need to be connected.
  • How does the Distance Sensor work? 
    • The Distance Sensor emits sound waves and measures the time it takes for them to bounce back. Measuring this determines the distance.

Our customer support specialists are on hand to ensure your implementation of Piper runs seamlessly.
View Support Docs or Contact Support
EXPANDED RESOURCES

Term Glossary


Engineer Someone who designs, builds, or fixes things to solve problems.

Sensor A device that produces an output signal to sense a physical phenomenon.

Conditional Statement A coding instruction used to compare values and express and make decisions, like an if-then statement.

List A sequence of several values grouped under a single name in code. A group of items or components. A tool used to store multiple pieces of information at once.

View Full Glossary

Standards Alignment


Individual Standards
  • CA 3-5.CS.1 Describe how computing devices connect to other components to form a system. (P7.2)
  • 3-5.AP.18 Perform different roles when collaborating with peers during the design, implementation, and review stages of program development.