Close menu

Resources


PIPER COMPUTER

Everything you need to teach STEAM effectivly using the Piper Computer Kit.

Educator Guides StoryMode Project Guides PiperCode Project Guides
PIPER MAKE

Teach fundamental STEM skills while providing a bridge to career connected learning.

Educator Guides
Best Practices Standards Glossary FAQ Educator Forum

EDUCATOR PORTAL

Close menu

ALL GUIDES


StoryMode

  1. Mars
  2. Cheeseteroid
  3. Treasure Hunt
  4. Chain Reaction
  5. Power Plant
  6. Rainbow Bridge
  7. Funky Fungi
  8. Breadboard Bluffs
  9. Return to the Cheeseteroid

  1. Pip Hop
  2. Bot Builder

  1. Ring Race
  2. Snake Trap
  3. Dark Maze
  4. Explosive Escape
  5. Chest Quest

PiperCode

  1. Blink
  2. Stop Light
  3. Light Show
  4. Tally
  5. Siren
  6. Circuit Design
  7. Debug
  8. Frog Frenzy

  1. Color Coded
  2. Ther-Mood-Stat
  3. Security Zone

  1. Randomizer
  2. El Pangolin (Simon)
  3. Beat the Buzzer
  4. 5-Button Synthesizer

PIPER COMPUTER

PROJECT GUIDES


YOU ARE HERE

PiperCode Sensor Explorer

Project 3 of 3

PiperCode Project

Security Zone


Beginner

30 Mins

Grades 3 - 8

Look for the graphic above
to launch the project
INTRODUCTION

Intruder Alert! Use your Distance Sensor to create an alarm

Students will use the Distance Sensor to create their own sensor alarm and learn to graph results.

PROJECT MATERIALS

Piper Computer Kit
Distance Sensor
2 Breadboards
5 Wires (2 yellow, 1 green, 1 red, 1 black)
Buzzer

PROJECT RESOURCES

Concepts

Students will learn how to use a Distance Sensor by connecting it and writing code. After that, they will look at the sensor’s data and change their code to measure distance in different ways. In the real world, this concept could be used in a car’s parking system. The car uses distance sensors to tell how close it is to other objects, helping the driver park safely.

Troubleshooting Tips

  • Have students check wiring against the diagram for accuracy.
  • Make sure students connect the print block above ‘if, do, else’ block when adding the ‘repeat forever’ loop block.
  • Make sure the positive side of the buzzer is pointed toward the right edge of the breadboard (see circuit diagram).

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

Step 1 Wire up your Distance Sensor

In this project, you will create a "security zone" for your Piper Computer. Using the wiring diagram and pin map, connect your Distance Sensor to the Raspberry Pi as shown.

GPIO Setup Distance Sensor Pins: 7, 6, 4

Step 2 Print the distance measurements

In order to read the distance measurements sensed by your Distance Sensor, you will need to print the values. Find the print block under Chip and drag it to your programming space.

Step 3 Set the Distance Sensor read out

To make sure your code prints a specific value read by the Distance Sensor, find the Distance Sensor block under Expansions and drag it within the print block as shown. Make sure the units are set to cm. Discuss: What would be different if we used inches?

Step 4 Add logic

Now find the if, do, else block under Logic. Drag it into your programming space. You will use this block to signal outputs when the Distance Sensor measures a particular distance.

Step 5 Add the inequality

Find the = block under Logic. Set the inequality to ≤ (less than or equal to). Place it in the if part of your conditional logic block and place a Distance Sensor block as shown. Make sure the Distance Sensor block units are in cm.

Step 6 Set the parameter

Find the integer block (showing 0) under Variable, drag it into the inequality logic block as shown. Set the integer value to 20 as shown. Discuss: How does setting the Distance Sensor value to 20 affect the output? What would be different if the value were 5?

Step 7 Wire up your buzzer

Next, wire up your buzzer using the diagram to set up your alarm system. Use the pin map to check your pin numbers.

GPIO Setup Buzzer Pins: 24, 22

Step 8 Add pin logic

Add a Turn Pin ON/OFF block found under Chip to both the do and else part of your conditional Logic block. Under do set it to Turn Pin ON, under else set it to Turn Pin OFF. Change both pin numbers to 22. Your code should match the image provided.

Step 9 Put it all together

Under Loops find the repeat forever block. Connect your print block to your if,do,else block and add the repeat forever block around your code snippet.

Step 10 Test your code and view data

Press START in the top left corner and test your alarm by positioning the sensor upright and slowly move your hand towards and then away from the sensor. Make sure you view the graph under Data --> Distance Sensor while you test. You can also view the numerical values by selecting the Console.

Step 11 Customize and extend

Adjust the Distance Sensor distance based on your preference. How close can someone come to your Piper Computer? Discuss: How would the alarm change if you used the units inches? Try it!

Completed!