Educator Resource Beam Break – Piper

BEAM BREAK

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Determine Piperbot's speed as he makes his escape!

To get started, head to Piper Make and hit this icon:

Time: 60 minutes

Age Range: 10+

Difficulty: Advanced

In this project, students are going to use the Beam Break Sensors to measure just how fast Piperbot's car can go.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Practice breadboarding and wiring
  • Review and understand computational concepts of:
    • loops: running the same sequence multiple times.
    • sequence: identifying a series of steps for a task
  • Demonstrate computational thinking core concepts, including:
    • Algorithm Design by creating an ordered series of instructions for solving similar problems or for doing 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.
  • Create programs that include events, loops, and conditionals.
  • Decompose problems into smaller, manageable tasks which may themselves be decomposed.
  • Test and debug a program or algorithm to ensure it accomplishes the intended task.
  • Perform different roles when collaborating with peers during the design, implementation, and review stages of program development.

STANDARDS ALIGNMENT

CSTA's K-12 Standards 

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-DA-07: Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea. Subconcept: Inference & Models; Practice 7.1

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2

CCSS Math

CCSS.MATH.CONTENT.8.F.B.4: Construct a function to model a linear relationship between two quantities. Determine the rate of change and initial value of the function from a description of a relationship or from two (x, y) values, including reading these from a table or from a graph. Interpret the rate of change and initial value of a linear function in terms of the situation it models, and in terms of its graph or a table of values.

CCSS.MATH.CONTENT.HSF.IF.B.6: Calculate and interpret the average rate of change of a function (presented symbolically or as a table) over a specified interval.

CCSS ELA

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

World-Class Instructional Design and Assessment (WIDA) English Language Proficiency Standards

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

California's K-12 Computer Science Standards

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.DA.9: Use data to highlight and/or propose relationships, predict outcomes, or communicate ideas.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

3-5.AP.17: Test and debug a program or algorithm to ensure it accomplishes the intended task.

Math Content Standards

CCSS.MATH.CONTENT.8.F.B.4: Construct a function to model a linear relationship between two quantities. Determine the rate of change and initial value of the function from a description of a relationship or from two (x, y) values, including reading these from a table or from a graph. Interpret the rate of change and initial value of a linear function in terms of the situation it models, and in terms of its graph or a table of values.

CCSS.MATH.CONTENT.HSF.IF.B.6: Calculate and interpret the average rate of change of a function (presented symbolically or as a table) over a specified interval.

Common Core English Language Arts

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

California English Language Development Standards

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

Michigan Integrated Technology Competencies for Students (MITECS)

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-DA-07: Use data to highlight or propose cause-and-effect relationships, predict outcomes, or communicate an idea. Subconcept: Inference & Models; Practice 7.1

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2

Michigan Math Standards

8-F.4: Construct a function to model a linear relationship between two quantities. Determine the rate of change and initial value of the function from a description of a relationship or from two (x, y) values, including reading these from a table or from a graph. Interpret the rate of change and initial value of a linear function in terms of the situation it models, and in terms of its graph or a table of values.

F-IF.6: Calculate and interpret the average rate of change of a function (presented symbolically or as a table) over a specified interval.

Michigan English Language Arts

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA English Language Development

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

Science Texas Essential Knowledge & Skills

Grade 3

(b)(2) Scientific investigation and reasoning. The student uses scientific practices during laboratory and outdoor investigations. The student is expected to:
(A) plan and implement descriptive investigations, including asking and answering questions, making inferences, and selecting and using equipment or technology needed, to solve a specific problem in the natural world;

(b)(3) Scientific investigation and reasoning. The student knows that information, critical thinking, scientific problem solving, and the contributions of scientists are used in making decisions.

Grade 4

(a)(1)(A) Within the physical environment, students know about the physical properties of matter including mass, volume, states of matter, temperature, magnetism, and the ability to sink or float. Students will differentiate among forms of energy including mechanical, light, sound, and thermal energy. Students will explore electrical circuits and design descriptive investigations to explore the effect of force on objects.

(b)(3) Scientific investigation and reasoning. The student uses critical thinking and scientific problem solving to make informed decisions. The student is expected to:

    (A) analyze, evaluate, and critique scientific explanations by using evidence, logical reasoning, and experimental and observational testing;

    (B) represent the natural world using models such as the water cycle and stream tables and identify their limitations, including accuracy and size; and

    (C) connect grade-level appropriate science concepts with the history of science, science careers, and contributions of scientists.

Grade 5

(a)(1) In Grade 5, scientific investigations are used to learn about the natural world. Students should understand that certain types of questions can be answered by investigations and that methods, models, and conclusions built from these investigations change as new observations are made. Models of objects and events are tools for understanding the natural world and can show how systems work. They have limitations and based on new discoveries are constantly being modified to more closely reflect the natural world.

(a)(3) Recurring themes are pervasive in sciences, mathematics, and technology. These ideas transcend disciplinary boundaries and include patterns, cycles, systems, models, and change and constancy.

Math Texas Essential Knowledge & Skills

Grade 8

(4) Proportionality. The student applies mathematical process standards to explain proportional and non-proportional relationships involving slope. The student is expected to:

(C) use data from a table or graph to determine the rate of change or slope and y- intercept in mathematical and real-world problems.

Algebra I

(3) Linear functions, equations, and inequalities. The student applies the mathematical process standards when using graphs of linear functions, key features, and related transformations to represent in multiple ways and solve, with and without technology, equations, inequalities, and systems of equations. The student is expected to:

(B) calculate the rate of change of a linear function represented tabularly, graphically, or algebraically in context of mathematical and real-world problems;

ELA Texas Essential Knowledge & Skills Grade 3

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) speak coherently about the topic under discussion, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively;

    (D) work collaboratively with others by following agreed-upon rules, norms, and protocols; and

    (E) develop social communication such as conversing politely in all situations.

ELA Texas Essential Knowledge & Skills Grades 4 & 5

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) express an opinion supported by accurate information, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively; and

    (D) work collaboratively with others to develop a plan of shared responsibilities.

(b)(13) Inquiry and research: listening, speaking, reading, writing, and thinking using multiple texts. The student engages in both short-term and sustained recursive inquiry processes for a variety of purposes. The student is expected to:

    (A) generate and clarify questions on a topic for formal and informal inquiry;

    (B) develop and follow a research plan with adult assistance;

    (C) identify and gather relevant information from a variety of sources;

    (D) understand credibility of primary and secondary sources;

    (E) demonstrate understanding of information gathered;

    (F) differentiate between paraphrasing and plagiarism when using source materials;

    (G) develop a bibliography; and

    (H) use an appropriate mode of delivery, whether written, oral, or multimodal, to present results.

§74.4. English Language Proficiency Standards

(c) Cross-curricular second language acquisition essential knowledge and skills.

(3) Cross-curricular second language acquisition/speaking.

(D) speak using grade-level content area vocabulary in context to internalize new English words and build academic language proficiency;

(E) share information in cooperative learning interactions;

(F) ask and give information ranging from using a very limited bank of high-frequency, high-need, concrete vocabulary, including key words and expressions needed for basic communication in academic and social contexts, to using abstract and content-based vocabulary during extended speaking assignments;

(G) express opinions, ideas, and feelings ranging from communicating single words and short phrases to participating in extended discussions on a variety of social and grade-appropriate academic topics;

(H) narrate, describe, and explain with increasing specificity and detail as more English is acquired;

CONCEPTS

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.

PARTS

Raspberry Pi Pico, breadboard, charging cable, M2M Green Jumper Wire, M2M Yellow Jumper Wire, 2 M2M Red Jumper Wires, 2 M2M Black Jumper Wires, Yellow LED, Red LED, Green LED, 330 Ω Resistor, 2 Beam Break Sensor Pairs

GPIO SETUP

Green LED GP13, Yellow LED GP14, Red LED GP15

OVERVIEW OF STEPS

Step 1: Piperbot Makes His Speedy Escape!

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 be peeling away in his Hot Wheels™ car? How on *Earth* will we measure how fast he's going?

In this tutorial, you are going to use the Beam Break Sensors to measure just how fast Piperbot's car can go!

One quick note: If you have already completed the Car Race tutorial - most of the build and circuit steps are the same.

Are you ready to get started? Click NEXT.

Step 2: Gather Your Stuff

Let’s start by gathering our supplies. For this project, you’ll need your Pico and breadboard, 6 jumper wires, 3 LEDs, 3 resistors, and both pairs of Beam Break Sensors.

The jumper wires don't have to be the same color as the ones in the diagram - you can use any color wires that you have.

You'll also need the parts that came with the Beam Break Sensors. 4 small wood pieces, 2 larger wood pieces, two black, C-shaped plastic pieces, and 1 Hot Wheels™ track, as shown.

 

Step 3: Build Your Beam Break Sensors

Your Beam Break Sensors have two parts - an emitter and a receiver. The emitter sends out a beam of infrared light and the receiver senses whether that beam is broken. So let's set up your Beam Break gates

To start, line up the Beam Break Sensor that has 3 wires (the receiver) with the hole on one of the smaller wood pieces.

Grab the C-shaped plastic piece, and hold the Beam Break receiver in the black plastic piece like the picture below. Then, hook the small wood piece in at the top and push in the bottom until the small wood piece is vertical.

Next, feed the wires through the hole on the bottom of the black plastic piece.

Now, grab one of the Beam Break Sensors with 2 wires. This is the emitter side of the Beam Break Sensor.

Install it and the small wood piece just like you did on the other side - use the picture below as a guide.

Then, feed the 2 wires through both holes of the black plastic piece.

Do this again for the other pair of Beam Break Sensors. When both sets are ready, click NEXT.

Step 4: Finish the Beam Break Sensors

Awesome, now we've got to make space for the track in between the emitter and the receiver!

Take the larger wood piece and push it straight down over the center of the black plastic piece.

The black plastic piece should stick through the cutout in the wood piece. Do this for both sets of Sensors.

Now that both Sensors are attached to the plastic and wood pieces, we will call the finished part a "Beam Break Module". When you finish building both Beam Break Modules, click NEXT.

Step 5: Attach the Modules

Look carefully at the image below. The orange Hot Wheels™ track will hook onto the Beam Break Module like this.

Attach both of the Beam Break Modules to the track, as shown below, and slide them down the track a little.

Look for the small card that came with your Beam Break kit. The card has a ruler printed on one side. Slide the Beam Break Modules apart on the track and use the ruler to make sure the Beam Break Modules are 8 centimeters apart.

When both Sensors are attached to the track, click NEXT.

Step 6: Wire up some LEDs

Awesome! Now that the track is ready, let's build the Beam Break circuits! Let's start by building the 3-LED circuit we built back in Traffic Light.
First, create a GROUND rail by connecting a GROUND pin to the (-) blue column on the edge of the breadboard, as shown at the top of the picture below.

Insert a Red LED into the breadboard across the center gap. Make sure the shorter leg of the LED is on the same side as the GROUND wire you just connected.

Connect a resistor between the short leg of the LED and the (-) blue column on the edge of the breadboard.

Then, connect a jumper wire from GP15 on the Pico to the long leg of the Red LED.

Repeat the steps above to add a Yellow LED connected to GP14 and a Green LED connected to GP13.

Click NEXT when you are finished building the LED part of the circuit.

Step 7: Connect the Modules

The Beam Break Modules have a lot of wires! Don't worry, they are actually easy to connect! We'll do it one step at a time, using the image below as a guide.

Start by connecting the (+) red column on the bottom of the breadboard to the 5V pin of the Pico using a jumper wire.

Next, connect the (-) blue column on the bottom of the breadboard to one of the GROUND pins on the Pico.

Connect all four of the black wires from the Beam Break Modules to the (-) blue column at the bottom of the breadboard. Then, connect all of the red wires from the Beam Break Modules to the (+) red column at the bottom of the breadboard.

Finally, connect the first Beam Break Module's white wire to GP6 on the Pico. Connect the second Beam Break Module's white wire to GP11 on the Pico.

Note that the first Beam Break Module is connected to GP6, and the second Beam Break Module is connected to GP11. When you send the car racing down the track, it needs to break the first beam, and then the second one. If you send it through backwards, the program we build won't work!

When your Beam Break Modules are connected, click NEXT.

Step 8: What's an IR Beam?

But wait, now that we have our Beam Break Modules all wired up, how come we can't see the light emitted by the emitter?


The emitter (the Sensor with two wires) is an infrared LED. Infrared light is special because we can't see it with our eyes.

If you have a cell phone or digital camera, the camera's Sensor can probably see it though! Here's a video clip from a cell phone showing the infrared glow from the emitter when it is connected.

The receiver, the other half of the Beam Break Module, uses a device called 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.

All we have to do to get the speed of the car is measure the time between when the first Beam Break Module turns off and when the second one turns off.

We can use that time difference and the distance between the two Beam Break Modules to calculate the speed of the car.

Click NEXT to start building the code to measure the speed of the car.

Step 9: Code the Beam Break

We want to do a bunch of things here— measure the time of each beam break, calculate the speed, display it, etc.

Instead of writing giant blocks of code, we can break these distinct tasks up into Functions, which are pieces of code that our program can call whenever we want to do a certain task.

Our first task is to measure the time the first beam breaks. How can we define a Function to do this?

Start by dragging out a to do something→return __ block from the Functions menu. Be careful, there are two block in the Functions menu that look similar. Make sure you have the one with the return at the end.

Then, change the name of the to do something block to "beam break time"

We want to wait until the the circuit switches off, right? So let's grab a wait until block from the Chip menu and place it in the to beam break time block. Then, grab an is pin block from the Chip menu and place it inside of the wait until block. Set the is pin block to pin 6.

Now that we're detecting when the beam breaks, we want to save the time when that happens to a variable. How can we do that?

Click the Variables menu and then click the Create variable... button. Name the new variable "first beam time".

Open the Variable menu again and drag out a set first beam time block. Connect it below the wait until block. Next, grab a chip clock block from the Chip menu and place it inside of the set first beam time block.

Our function will now capture the time when the car breaks the first beam.

We need to create another variable to store the time when the second beam is broken. click the Variables menu and then click the Create variable... button. Name the new variable "second beam time"

Right-click the wait until block and select Duplicate. Connect it below the set first beam time block. Change the pin variable on the wait until block to pin 11. Next, right-click the set first beam time and select Duplicate. Connect the new block below the last wait until block. Change the variable on the set block to second beam time.

Click NEXT.

Step 10: Tick Tock... Calculate the Time

How long did it take for the car to go from breaking the first beam to breaking the second? To figure this out, we need to subtract the first beam break time from the second beam break time.

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).

Grab a second beam time block from the Variables menu and place it in the left side of the __ - __ block. Then, grab a first beam time block from the Variables menu and place it in the right side of the __ - __ block.

Woot! We've done all the work, now how can we see the results? Since you defined a function which returns the time difference, all we have to do is print that result!

Grab a start block from the Chip menu and drag it onto the workspace. Then, grab a repeat forever block from the Loops menu and connect it to the start block. Next, grab a print block from the Chip menu and place it inside of the repeat forever block.

Change the wait time on the repeat forever block to 0.1 seconds, and delete the "_" block inside of the print block by dragging it to the trash can.

Finally, grab the beam break time block from the Functions menu and place it inside of the print block like this.

Now, you're ready to test it out! Click NEXT.

Step 11: Test Your Sensors

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.

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.

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!

When you are finished testing the Sensors, click STOP, and then click NEXT.

Step 12: Ready, Set, Go!

Oh no! As Piperbot speeds away from the incoming Cheesteroid he runs into a pesky traffic light! Can you code up the traffic light to speed up his escape?

Let's build some code that will light up the LEDs in order to make a "Ready, Set, Go" indicator so we know when to push our Hot Wheels™ car down the track.
To make a traffic light, the red LED needs to light up first for 2 seconds. Then, the red LED will turn off and the yellow LED will turn on for 2 seconds. And finally, the green LED will turn on, indicating "Go Go Go"!

Click NEXT to learn how to build the code for the Ready, Set, Go! lights.

Step 13: Code the Lights

Let's build another 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.

Step 14: Put it All Together

Now that we have our functions, let's put it all together.

We want the Ready, Set, Go! lights to start first, so grab a ready set go lights block from the Functions menu and place it right above the print block inside of the repeat forever block.

Next, our program needs to turn the green LED off when the car goes through the Sensors. Grab a turn pin block from the Chip menu and place it in the repeat forever block after the print block. Set the block's variables to 13 and OFF.

Let's clean up the workspace a bit. Right-click the to beam break time block and select Collapse. Do the same thing to the to ready set go lights block. Collapsing a group of blocks lets them keep working, but shrinks them so they take up less space.

Step 15: Calculate the Speed

How can we figure out how fast the car is going?

Our code calculates the time the car travels between the first and second beam, and we already know how much distance there is between the two beams - so we have everything we need!

Speed is the distance something travels divided by the time it takes to travel that distance.

All we need to do is take the distance, which is 8 centimeters, and divide it by the beam break time.

Start by opening the Variables menu and create a new variable named "car speed". Open the Variables menu again and drag out a set car speed block. Connect the set car speed block between the ready set go lights block and the print block:

Drag out a __ + __ block from the Logic menu and place it in the set car speed block. Change the + (plus) to a ÷ (divide by). Grab a 0 block form the Values menu and place it into the left side of the __ ÷ __ block. Grab the beam break time block from inside the print block and place it into the right side of the __ ÷ __ block. Then, change the 0 to an 8.

This will calculate the car's speed in centimeters per second, but you are probably more used to speeds in miles per hour or kilometers per hour. All we need to do is one more calculation to convert the speed!

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.

Step 16: Speed Reader

All that's left is to print the speed!

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 place it into the top input in the create text with block.

Next, grab a "_" block from the Values menu and place it into the bottom input in the create text with block. 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!

Step 17: Speed Away!

Ready to measure the speed of your Hot Wheels™ car?

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!

Start off slow and steady, but then feel free to speed!

How fast is your car going? While it might seem like your car's speed is a low number, remeber that your 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!

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 set up alarms in your code to beep if you go over a certain speed? How fast can you get Piperbot away from the Cheesteroid?

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

Step 18: You Finished!

Click EXIT to return to the menu and start your next coding challenge. Head over to Car Race to challenge your friends!