PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Base expedition

Mission 10 of 13

Base expedition: Mission 10 of 14

Security Zone


Beginner

1 hour

Grades 3 - 8

MISSION OBJECTIVE

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?”

View student interface at make.playpiper.com
MISSION CHARACTERS

Piperbot

Pip
MISSION MATERIALS

Computer with USB port and Chrome or Edge browser
Piper Make Base Station

MISSION RESOURCES

Learning Goals

  1. Students will build a “security zone” around their Distance Sensor and sound an alarm when a Zomar breaches the zone.
  2. Students will learn to use if/then statements in code to create conditional statements.
  3. 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

Hardware Diagram






Tutorial Steps

Security Zone

You're going to need an Ultrasonic Range Finder for this project—which you might have on hand if you're one of our earliest Monthly Makers Club members OR if you have an Extended Starter Pack. If not, don't worry -- head over to playpiper.com and search for the Sensor Explorer to get three snazzy sensors.

If you've got your Ultrasonic Range Finder sensor, let's get started!

Let's pretend you're a dolphin for a second. Go ahead, make your best dolphin face, we'll wait. So the way dolphins orient themselves is through a process called echolocation, where they let out a series of clicks which reflect off of objects around them. Dolphins then sense the sound waves coming back and can figure out where objects are in space — which is exactly what our range finder does as well!

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:

So let's go back to pretending we're a bionic dolphin and use our echolocation to detect where objects are in space around us!

To do this, we're basically going to want to print out the distance measured by the sensor, right?

So let's grab a start block and drag it to your programming space. Then find the print block under Chip menu and drag it to the start block.

Cool, so we know to print something but what do we want to be printed? Let's tell the program to print the input from the Ultrasonic Range Finder!

We want to read the sensor more than once, so start with a repeat forever block from the Loops menu and connect it to the start block.

Find the range finder block under Sensing menu and drag into the print block as shown. When you place the range finder block where the "_" block is, the "_" block will be displaced. That's fine, go ahead and put the "_" block in the trash can.

Now change the pin input to the GPIO pin that we connected the yellow wire to: GP22.
Click NEXT.

Go ahead and test the program by clicking CONNECT and then clicking START.

Check out the CONSOLE tab at the bottom of the workspace. Do you see the readings change as you move your hand in front of the sensor?

After you've experimented with the distance sensor, click STOP and then click NEXT.

Now that we have a sensor that measures how close objects are, let's use it to create a Security Zone!

Basically, if an object comes within the range of our Ultrasonic Range Finder, let's set off an alarm. So how do we do that? Well, we want to set up a conditional statement, with an alarm set off if an object is detected. We can do this using an if _ do block under the Logic menu. Go ahead and drag one of those into the repeat forever block. Use the one with the inequality already in it:
Click NEXT.

Let's think about what we want the code to do! Basically, if there is an object within a certain range, we want the program to do something (set off an alarm) or we want it to stay silent, right? And we don't want that test to just happen once right, we want to test repeatedly?

So let's set up the if statement to test if there is an object within a certain range. Duplicate the range finder block and drag the new one to the left side of the _ = _ block. Then set the inequality to ≤ (less than or equal to).

Drag a number value block from the Values menu to the left side of the _ = _ block. Change the value from 0 to 50.

Finally, change the wait time of the repeat forever block to 1 second:
Click NEXT.

Okay cool, so we've set up the test, but what do we want to happen if the answer to the question "is there something within 50 cm of the sensor?" is TRUE?

Let's set off an alarm!

There are many different sounds you could play in your program if the condition is met. Do you want a loud alarm to wake you up? Or a funny sound to make you laugh?

Whichever it is, drag a play sounds block from the Sounds menu and place it in the do statement in the if block. Then, pick which sound you want the program to play! You can find lots of different sounds in the Sounds menu.

You may change the sounds at any time by changing the blocks in your program:
Ready to try it? Click NEXT.

Okay drumroll please... Let's click that START button to test your alarm.

Position the sensor and move your hand towards and then away from the sensor. Check the CONSOLE. Do you see the measurements printing?

Check the PYTHON tab. Do you see any text that looks like what the blocks you dragged and dropped above?

If you don't hear any sounds - check your computer's volume. The sound blocks actually send a command back to your computer that tells it to play a sound!

Click NEXT.

Let's try using the DATA tab to visualize the output from the sensor.

Replace the print block in your program with a graph number block from the Actions menu:
Click on the DATA tab at the bottom of the workspace to open it, and click START to run your program again.

What is the graph showing you?

Click STOP and then click NEXT when you've figured it out!

Maybe you want your Security Zone to be a little narrower or a little wider. Let's adjust the Ultrasonic Range Finder distance based on your preference!

How close can someone come to your sensor without tripping the alarm? How would the alarm change if you used units of inches?

Try it, and when you're finished, click NEXT.

Whew, setting up security systems is hard work! But hey, that's not the only place sensor like these are used—in fact, self-driving cars actually use sensors like these to make sure they're not running into things while on the road!

Can you think of any other places where you might use a range finder like this?
Click NEXT.

Congratulations, you built your own Security Zone! Click EXIT to go back to the start screen and try out more projects and tutorials!

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


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.

View Full Glossary

Standards Alignment