PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Motion expedition

Mission 1 of 3

Motion expedition: Mission 1 of 3

Beam Break


Advanced

1 hour

Grades 3 - 8

MISSION OBJECTIVE

Learn to use the Beam Break sensors and measure how fast Piperbot's car can go.

Vroom, vroom... Piperbot is making his daring escape as the Cheeseteroid hurtles toward Earth! Will Piperbot make it in time? How fast does he have to peel away in his Hot Wheels™ car? How on *Earth* will we measure how fast he's going?

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 or Starter Kit
Beam Break

MISSION RESOURCES

Learning Goals

  1. In this project, students will apply what they've learned about loops and wiring in order to create a program that tracks the speed of a moving object.
  2. Students will understand the differences between Potential and Kinetic Energy.
  3. Students will demonstrate computational thinking core concepts, including:
    • Algorithm Design by creating an ordered series of instructions for solving similar problems or performing a task, such as turning a light off and on in the right order.
    • Simulation by developing a program to imitate the real-world process of a stoplight.

Career Connections

Urban and Regional Planner: Salary $79,540/yr
Sports Official: Salary $36,010/yr
Physicist: Salary $142,850/yr
Avionics Technicians: Salary $75,450/yr

Hardware Diagram




Code Diagram




Tutorial Steps

Beam Break

Wheldon Brothers, you guys made it to the finals!! Congratulations!!
Thanks Pip! This next challenge is going to be hard though - we have to figure out how to jump across Valles Marineris, that huge gorge!!
YIKES! That gorge is HUGE! You'd have to be going so fast to make it across! Is it even possible?
Looks like we're going to need your help to figure it out!
In this mission, you're going to use the Beam Break ramp to figure out how fast your car can go!

Set up two desks to see if you can accomplish the mission of jumping your Hot Wheels™ car between them.
Click NEXT.

It's cool to see how they're putting together those sensors. Check out those blueprints!
Follow the build instructions for Beam Break Sensors.
Not sure what version you have? Take a look at the image below:

Oh this track also has those fancy starting lights that tell Oliver and Sebastian to get ready... get set ... go!!
Start by grabbing the following inventory:
Wire up the 3 LEDs like you see here (it's the same wiring as Traffic Light!):
When you're done, click NEXT.

Oof there's a lot of wires down here with the Beam Break modules! But it looks like they're easy to connect.
Use your blueprint to connect your sensors. The wiring is different for VERSION 1 versus VERSION 2.

Wire colors might be different but make sure to match the pin on the sensor module to the correct Pico GPIO pin!


For this circuit, you will connect:
  • GND to G (ground)
  • OUT A to GP6
  • OUT B to GP11
  • VCC to 3V
Follow this guide and use the wiring diagram below:
Remember, the DIGITAL VIEW is a handy way to see the GPIO pin locations!
When you are done, click NEXT.

Hey Piperbot and Pip! Thanks for coming to cheer us on—you guys excited to see us break that IR beam first at the finish??
Huh? I don't see any light beam! I'm looking at the emitter (the sensor with two wires)... What's up with that?
Ooh, it's an infrared light, which you can't see with your eyes! But we often feel it as heat which is really cool.
Oh! Because my vision is a digital camera like the one in cell phones, I can see it! This is how it looks to me...
The receiver on the other side is detecting when it "sees" the infrared light! And when it doesn't, it means my car is in the way and I win!
The receiver is a phototransistor. If we break down the word, "photo" means light (think photosynthesis), and "transistors" are digital switches. So a phototransistor is a light-sensitive digital switch!

Shining infrared light on the phototransistor turns it on, and when the car blocks the infrared light, the phototransistor turns off:
Click NEXT to start building the code to measure the time when the car crosses the beam!

Pip, do the starting lights in Mars races usually spend 2 seconds on red, yellow, and then turn green?
Yep! To make a Ready, Set, Go light, the red LED needs to light up first for 2 seconds - that means "Ready". Then, the red LED will turn off and the yellow LED will turn on for 2 seconds. That means "Set". And finally, the green LED will turn on, and that means "Go!"
Click NEXT to learn how to build the code for the Ready, Set, Go! lights.

Let's build a Function to control the LEDs. Drag out a to do something block from the Functions menu. Then, change the name of the blocks to "ready set go lights".

Drag a turn pin block from the Chip menu and place it inside of the to ready set go lights block. Drag a wait block from the Chip menu and connect it below the turn pin block. Set the variables of the turn pin block to pin 15 and ON, and set the wait time on the wait block to 2 seconds.
Next, right click the turn pin block and select Duplicate. Connect the new block below the wait block. Change it from ON to OFF.

This will turn the red LED on, wait for two seconds, and then turn it off. We need the same code again, but using pin 14 to turn on the yellow LED for 2 seconds.

Use the right click button to duplicate your blocks and set them to pin 14:
Your code will now turn on the red light for 2 seconds, and then turn on the yellow light for 2 seconds.

All the function needs to do now is turn on the green light. Right click one of the turn pin blocks and duplicate it. Set the variables to pin 13 and ON, and connect it below the last block inside of the function:
Click NEXT.

Okay, now that we've got our starting lights, our code needs to measure the time the first beam breaks... Ooh since it's another thing to DO, I guess that's another function!
Drag out a to do something→return __ block from the Functions menu. Make sure you have the one with the return at the end. Name your function "beam break time".
Perfect! Okay so we want to wait until the first circuit switches off and then write down the time right? How do we do that?...
Add a wait until block and add a block to detect when the first circuit is broken or when pin 6 is HIGH when pulled UP.

When this happens, set a variable called "first beam time" to write down the "chip clock" time.
Oh I get it! Now we see when the car breaks the second beam and it we can figure out how fast it went through both!
Repeat the steps to create a "second beam time" which is assigned when the second circuit is broken or when pin 11 is HIGH when pulled UP.

To do this, right click your blocks and change the different values to get the following code:
Click NEXT.

Yep, I got it! So now we subtract the first beam time from the second beam time... That's how long it took the car to get from point A to point B!
Grab a __ + __ block from the Logic menu and place it inside the to beam break time block's return value. Then, change the + (plus) to a - (minus) and add your beam time variables.
Now, you're ready to test it out! Click NEXT.

Whew time to put it all together... I'm feeling nervous for you guys! Let's make sure we have everything—lights on, car goes, first beam, then second beam, then subtract... I think that's the sequence!
Hold up, where does my time show up exactly? Could we have it print on that big screen up there for all our adoring fans to see?
Grab a START block and add a loop to cycle through the functions. Add the ready set go lights block from the Functions menu and then add a print block with the beam break time.
Next, our program needs to turn the green LED off when the car goes through the Sensors so grab a turn pin 13 OFF block and add it here:
Whew that's a lot of code! Let's clean up the workspace a bit. Right-click the to ready set go lights block and select Collapse. Do the same thing to the to determine winner block:
Click NEXT.

Click the CONSOLE tab at the bottom of the workspace to open the console up.

Make sure your Pico is connected to your computer, then click CONNECT and click START.
Let's give it a shot! Push your Hot Wheels™ car down the track - make sure you do it in the right direction, so that the car reaches the first Beam Break Module and then the second! If you accidentally send it down in the wrong direction, click STOP, and then click START again.
0.195313
0.5625
0.367188
0.203125
0.21875
0.148038
The console should show a number when the car passes through both Sensors. This is how many seconds it was between when the first beam was broken and when the second beam was. It's probably a very small number!

Click NEXT.

This time thing is cool but usually I say how many miles per hours I'm going when I'm flooring the pedal... That's speed right? How do we get that?
Speed is the distance something travels divided by the time it takes to travel that distance.
Right! So if we already know the distance between the two beams is 8 centimeters, we just divide it by the beam break time. I think we could calculate that in the code...
Create a new variable named "car speed" and set it to be a logic block. Change the + (plus) to a ÷ (divide by). Grab a 0 block form the Values menu and change it to 8 and add a beam break time block to the logic block:
Um... Sebastian, have we ever used centimeters per second? We usually say speeds in miles per hour or kilometers per hour. I think it's just some math to convert it though!
If you want the speed in miles per hour, change the 8 to 0.179. Why this weird number? It's all about units here—we're trying to get from cm/s to mi/hr.

Imagine it took our car 8 seconds to get 8 cm, our speed would be 1 cm/s. That's 0.0000497 miles traveled in 8/3600th of an hour = 0.0223 mi/hr. Since your break beam time won't be 8 seconds, your conversion factor is 0.179.

If you want the speed in kilometers per hour, change the 8 to 0.036.
Click NEXT.

Sweet! Let's get that speed up on that board for everyone to see! We can just print it right...
Grab a create text with block from the Values menu and place it into the print block. Then, grab a car speed block from the Variables menu and a "_" block from the Values menu. Based on your unit conversion, type in either "miles per hour" or "kilometers per hour".
Now that your program is ready, click NEXT to try it out!

Click the CONSOLE tab at the bottom of the workspace to open it up so you can see your car's speed. When you are ready, click START. Wait for the green light, and then send your car down the track through the Sensors!
Oh I can't believe it's time for the finals! What's the fastest speeds you guys are getting on the ramps? Do you think it'll be enough to make it across the gorge?
I think we can do it! It seems like a low number but our Hot Wheels™ car is small - it's 1/64th the size of a real car. That means that you can multiply your Hot Wheels™ car's speed by 64: 2.0 mph × 64 = 128 mph!
Although psst, when you are ready to drive a full-sized car for real, make sure you always follow the speed limit unless you are on a race track!
Can you clear the gorge? What if you try some higher slopes? Can you set up alarms in your code to beep if you go over a certain speed?

When you are finished, click STOP, and then click NEXT.

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

  • Are you receiving a ZeroDivisionError?
    • Check the wiring between your sensor and the Pico.
    • Check to make sure your track is not covering the sensor.
  • Are you concerned that your sensor is not working? Let’s test it!
    • Open a new project in Creative Mode and use the Beam Break Sensor Test Code. Once uploaded, send your car down the track and your Yellow LED should light up. You can also test this by placing your finger in front of the emitter sensor.

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

 What are Pull-Up and Pull-Down Resistors?

Term Glossary


Velocity Another word for speed or the rate of change in an object’s position. (MB / BB)

Acceleration Measurement of the change in velocity or how much an object speeds up over time (MB / BB)

Kinetic Energy Energy an object has due to its motion. It can be converted from potential energy. (MB / BB)

Potential Energy Energy stored by an object due to its state or position; can be converted to kinetic energy. (MB / BB)

Force A push or pull on an object, measured in pounds (imperial) or Newtons (metric). (MB / BB)

Momentum Measurement of mass in motion equal to the mass times the velocity of an object. (MB / BB)

View Full Glossary

Standards Alignment


Individual Standards
  • CA 3-PS2.A Make observations and/or measurements of an object’s motion to provide evidence that a pattern can be used to predict future motion. (1.ESS1.A; 4.PS4.A; MS.PS2.A; MS.ESS1.B)
  • CA 4-PS3.B Ask questions and predict outcomes about the changes in energy that occur when objects collide. (K.PS2.B; 3.PS2.A; MS.PS2.A; MS.PS3.A; MS.PS3.B; MS.PS3.C)