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.comMISSION CHARACTERS
MISSION MATERIALS
Computer with USB port and Chrome or Edge browser
Piper Make Base Station
MISSION RESOURCES
Learning Goals
- Students will use the distance measured by your Distance Sensor to play different notes like an instrument (particularly like a drum!).
- Students will understand how to use variables, loops, and conditionals to convert distances to different notes using list mapping.
- Students will understand how the Distance Sensor measures distance using sound waves that bounce off objects.
- 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.
- “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 DrumReady? Let's do it!
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
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.
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.
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:
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:
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!
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!
Blueprint
OPEN IN BLUEPRINT VIEWER DOWNLOAD
Have an different version? Look for more information on the Support Page.
Troubleshooting Tips
-
Is the Distance Sensor 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
Circuit A conductive path for the flow of current or electricity.
Power The current or flow of electric charge and voltage.
Microcontroller An integrated circuit containing a microprocessor with memory and associated circuits.
Variables A value that can change depending on conditions or information passed to the program. A storage location with a symbolic name used to keep track of a value that can change while a program is running (similar concept to using X and Y in an algebraic equation). Variables are not only numbers; they can also hold text, including whole sentences (strings) or logical values (true or false).
Input Device A hardware device that sends data to a computer, allowing interaction and control.
Output Device A piece of hardware that converts information into a form humans can sense and understand.
Standards Alignment

