Learn how to set off an alarm when an object breaches a set perimeter.
In this mission, you will help Piperbot and Pip detect when an object breaches a set perimeter using the Distance Sensor and sound an alarm. Ask students: “What do you think home security systems use as the sensor? What about smart doorbells?”
Students will build a “security zone” around their Distance Sensor and sound an alarm when a Zomar breaches the zone.
Students will learn to use if/then statements in code to create conditional statements.
Students will understand how the Distance Sensor measures distance using sound waves reflected off objects.
I WILL BE ABLE TO...
Understand how sensors detect changes
Code an alarm that is triggered when inputs reach a threshold
Learning Activities
ELA Extension: Security Zone Story
Pair students up or allow them to work independently based on writing level and preference. Students will write a narrative or procedural account of an event where their robot’s security system was triggered, using descriptive language and cause-and-effect structure.
Students begin by setting the scene. Ask: Where is the security system located? Options might include: Mars Base 4, the school science lab, or a secret alien bunker.
Next, students describe the moment the sensor detected something:
What triggered the alert?
Who or what entered the zone?
Was the alert caused by movement, sound, or light?
Students then describe how the system (or characters) responded:
Was it a false alarm?
Was there a real threat?
Was it something unexpected or silly?
Students will write using a narrative voice, past tense, and sequencing words like first, then, suddenly, finally. Encourage inclusion of dialogue, sound effects, and emotional reactions to bring the scene to life.
Bonus vocabulary words to include: sensor, input, trigger, detection, condition, alert, zone
EXTENSION: Students turn their stories into short graphic panels or comic strips showing the moment of detection, the alarm being triggered, and the characters’ reactions.
ELD Extension: Motion Detection Roleplay
Pair students so that each English Learner (EL) is working with a fluent or higher-level EL. Students will practice speaking, listening, and cause-effect sentence structures through visual supports and interactive storytelling related to motion detection.
Begin with Visual Vocabulary instruction using picture cards, gestures, or real objects to introduce key terms: sensor, zone, alarm, detect, move, stop, alert
In Partner Roleplay, one student acts as the “security bot” while the other moves through the sensor zone (e.g., crossing a line, waving an arm). The “bot” reacts with a sound, gesture, or phrase.
Students describe the interaction using sentence frames such as:
"The bot detected me when I ___."
"The alarm went off because ___."
After switching roles, students retell and report what happened by drawing a picture and writing or saying a cause-effect sentence. Examples:
“When I walked into the zone, the light blinked.”
“The robot made a sound because I moved too fast.”
OPTIONAL CLASS SKIT:
Small groups act out their motion detection scenes using simple props and sound effects.
Focus on sequencing, expressive tone, and correct use of verbs and cause-effect language.
Math Extension: Sensor Range & Thresholds
Pair students together or allow them to choose their partners. Partner A will operate the sensor system while Partner B tests how close an object can get before triggering the alert. Then, they will switch roles.
Connect back to the Security Zone activity and ask students to estimate: “At what distance will the sensor detect an object?” Record student predictions on the board before testing.
Start students off with objects like a hand, pencil, or eraser. Measure the distance at which the alert goes off using a ruler or tape measure. Students record the distances in centimeters or inches.
Have pairs switch roles and repeat the process with a new set of objects. Then, have them organize their results into a chart or simple bar graph.
Ask students to describe their findings using math language:
“The pencil triggered the alert at less than 5 cm.”
“The eraser was detected at a greater distance than the toy.”
Observe student reasoning and encourage them to explain:
“What object triggered the alert first?”
“Was the sensor consistent each time?”
“How would changing the detection threshold affect results?”
Finally, challenge students to write simple detection rules using logic terms like:
If distance < 6 cm, then alert.
If distance ≥ 6 cm, no alert.
Encourage them to decide which role they preferred—the one collecting the data or the one interpreting it.
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
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
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.