PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Base expedition

Mission 5 of 13

Base expedition: Mission 5 of 14

Reaction Game


Intermediate

1 hr

Grades 3 - 8

MISSION OBJECTIVE

Build and code a game that will test your reflexes.

Can you beat the Wheldon Brothers? Or better yet, can you beat a fellow student? In this mission, students will build and code an LED to light up at a random time and then determine who can press their button the fastest.

View student interface at make.playpiper.com
MISSION CHARACTERS

Piperbot

Pip

Sebastian Wheldon

Oliver Wheldon
MISSION MATERIALS

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

MISSION RESOURCES

Learning Goals

  1. Students will build a head-to-head game of skill and code a script to select a winner based on who hits their button fastest when a light comes on.
  2. Students will understand how random values can be assigned to a variable.
  3. Students will play the game with a friend to test who has the fastest reflexes.
I WILL BE ABLE TO...
  • Build circuits with two buttons and a light
  • Code a game to race my friend to press our button the fastest when the light turns on
  • Understand how random values are assigned to variables

Learning Activities

ELA Extension: Reaction Race Feature Article

  • Pair students together or allow them to work independently, based on writing level and project goals. Each student will write an engaging feature article that recounts a high-stakes reaction-time tournament using vivid language, dialogue, and comparisons.
  • Begin by setting the stage: Explain that the class is hosting the Interplanetary Reaction Race Rally, where robots and humans compete for the fastest reaction time in the galaxy.
  • Have students test the Reaction Game three times, recording both their own scores and a classmate’s. Encourage them to take notes like a journalist—observe, compare, and look for standout moments.
  • Students will then write a feature article that includes:
    • A headline and byline
    • A lead paragraph with a compelling hook (e.g., “Who won? By how much?”)
    • Quotes from competitors or coaches (e.g., Pip, Piperbot, or friendly aliens)
    • Vivid comparisons (“0.28 s—quicker than a lightning flash on Mars!”)
    • Cause-and-effect phrases (“Because the loop reset too late, the defending champ missed the button.”)
  • Once drafts are complete, partners will trade articles and provide feedback on clarity, vocabulary, and flow. Final articles can be published or shared with the class.
  • EXTENSION CHALLENGE: Invite students to design a magazine-style layout, including infographics or leaderboards showing top reaction times.
Bonus points for accurately using vocabulary words: input, loop, variable, random, output, reaction time

ELD Extension: Reaction Time Responses
  • Pair students up so that one English Learner (EL) works with one other student who is a non-EL or a higher-level EL.
  • They will start by observing a quick action (e.g., a blinking light, a clap, or a button press) and respond verbally using a full sentence to describe what happened. Examples: “The robot pressed the button when the light turned on.” or “I reacted fast because the signal blinked.”
  • Partners will then take turns giving each other reaction challenges (e.g., raising a hand or blinking a light) while the other partner responds and describes their action aloud using a sentence frame.
  • After practicing both roles, students will reflect on their experience by retelling what happened, including whether their reaction was fast or slow and why. Encourage use of comparative and cause-effect phrases such as:
    • “My reaction was faster than my partner’s.”
    • “Because I hesitated, I was slower.”
  • Students will then perform a short skit or demonstration of one of their reaction scenarios, narrating it using their sentence frames. Optionally, recordings of the performances can be used for peer or self-assessment.
  • Bonus vocabulary words to include: reaction, signal, respond, fast, slow, button, light, time, compare.

Math Extension: Reaction Time Data
  • Pair students together or allow them to work independently based on math level.
  • Each student will begin by playing the Reaction Game five times and recording their reaction times in milliseconds.
  • Students will organize their data in a table, then create a visual representation such as a line plot or bar chart showing their five recorded times.
  • Using their data, students will calculate the mean, median, minimum, maximum, and range. Then, compare their results with a partner or group to identify trends such as consistency or variability in reaction time.
  • As a class, discuss the following questions to build interpretation skills:
    • “What does a lower mean tell us?”
    • “Who had the greatest variability?”
  • For an extension, students will convert their fastest time to seconds by dividing by 1000. Then, use the class average reaction time to predict how many rounds could be completed in one minute.

Career Connections

Software Developer: Salary $127,260/yr
Electrical Engineer: Salary $127,260/yr
Data Scientist: Salary $103,500/yr
Construction Manager: Salary $101,480/yr

Hardware Diagram




Code Diagram




Tutorial Steps

Reaction Game

Hey there! We're Sebastian...
...and Oliver Wheldon, Earth racers here to compete in the Intergalactic Championships! Ready to warm up?
You're on! When the lights turn green, the first one out of the gate wins!
Let's build a Reaction Game to test how Pip and Piperbot's reflexes match up against our all-star racers!

Let's gather our supplies to get started.
Ooh, I know! Hit that expand icon in the top right-hand corner of the picture!

Okay, let's start by building the indicator light for the traffic gate in front of us!
Ooh, like the LEDs we've built before? We can do that!
You will build a circuit similar to the Traffic Light circuit you built in the last tutorial. Using Resistors and Jumper Wires, as shown in the picture below, connect the following LED/pin pairs: red to GP15, yellow to GP14, and green to GP13.

Don't forget to use a Jumper Wire to connect the Ground rail!
Which side of the LED is where the current flows INTO from the power supply?
Short Lead (Anode)
Long Lead (Anode)
Short Lead (Cathode)
Long Lead (Cathode)

The long lead of the LED is the anode. Remember that the anode is where the current flows into a device, while the cathode is where the current flows out!
Once you've added your LEDs, click NEXT.

Perfect! This wiring looks kind of like how we set up the traffic lights! Let's make sure it works.
Drag a start block from the Chip menu. Then grab and connect a turn pin block. Change the pin number variable to GP15 (where your LED is connected) and set it to ON.

Then add a wait block right below that.

Do this again for GP14 and GP13:
Click CONNECT and then click START. Make sure each LED lights up; if they do, click STOP.

If one or more of your LEDs isn't working, double-check your wiring and make sure that the LEDs aren't connected backward.

Once your circuit is working, click NEXT.

Oof. We'd definitely win if we controlled when the light turned on. What a bummer that when this gate opens is kind of random.
That's okay! We can make the light "wait" a random amount of time before it turns on. Let's find the code!
Add a wait block right after the start block. Let's change the 1 second to the random integer from the values menu.
If our random number ends up being 100, we don't have 100 seconds to waste, though! Let's change that to 8!
Change the range from 1 to 100 seconds to 3 to 8 seconds instead.
Once you're done, click NEXT.

On Earth, we actually have 5 lights to start our races!
Yeah! The lights each turn on, then after a random amount of time, they all turn off at once, and that's when we GO!!!!
Piperbot, can we make our lights do that?
Sure! Let's rearrange our code so the random wait is at the end, and then add code that turns them all off at the same time!
You'll need to grab a few more turn pin blocks from the Chip menu and set them to OFF. Arrange your code blocks to that they look like this:
Try your new code out by clicking START. If it works like you expected, click NEXT.

If not, double-check your code blocks to make sure they are arranged correctly.

Okay, our lights are ready! Now, how do we floor the gas pedal? Let's add the buttons that we'll be racing to press!
Add 2 Pushbuttons to your Breadboard. Use Jumper Wires to connect one side to the Ground Rail and the other side to GP12 and GP11, as shown in the picture below:
Oh, I get it. When I press the button, the current flows from the pin all the way to GROUND, making a circuit!
Click NEXT when you finish adding your buttons.

Pip! I hit my button when the light came on, but it's not saying I'm the winner!
Oh, silly us! Nothing in the code detects and tells us whose button is pressed first.
Wait! I remember the Earth scientists saying that when code takes some input like our button presses and "does" something with it, it's called a FUNCTION.
Drag out a to do something block from the Function menu and change the name of the function to "determine winner".
After you've added that block, click NEXT.

Which blocks do we put in there? How do we know who wins?
Since the winner could be us or the Wheldon brothers, I guess it's kind of "variable." Wait, that's on that menu!
Create a variable (from the Variables menu) and call it winner.

Then, grab a set winner to block and place it in the determine winner function:
Click NEXT.

Psst. If we set the winner variable to read "Piperbot and Pip" would we win all the time?
Hmm. Yeah, I guess it would, but that's no fun! The code needs to see IF we press our button first or IF the Wheldons do.
We'll need an if-else block to test IF either button is pressed first (or else no button is pressed).

Drag an if-do block from the top of the Logic menu into your determine winner function block to get started:
We still need to turn the if-do block into an if-else if block.

To do this, click the blue gear icon on the if-do block. This will bring up a new menu that lets you change the shape of the if block:
In that menu, drag an else if block over to the if block and connect it.

Click the blue gear icon again to close the menu.

Click NEXT when your if-else if block is ready.

Time to pick our lucky button! I like the GP12 button. Could we code our game so that IF GP12 is pressed first, "Pip and Piperbot" are the winner?
Sure! And IF GP11 is pressed first, the "Wheldon Brothers" can be the winner.
What's a function?
A code component that can store different values
The circuitry that allows the Pico to communicate with your computer
A set of code that does something and can return a result
A code component with only a TRUE or FALSE value

A function is a set of code that executes and can return a result, like the function that determines the winner here. A variable can take on different values, and a Boolean variable can be specifically TRUE or FALSE.
How would you code that? Click NEXT to find out!

Hmm. There are two ifs. I guess the two questions are, "Is the GP12 button pressed?" or "Is the GP11 button pressed?"
In our code, we use "LOW when pulled UP" to detect that a button connected to GROUND is pressed.

Drag out a is pin LOW when pulled UP block and add it to the first test of our if-else if block. Change the pin to pin 12 and then duplicate it for pin 11.

Duplicate the set winner to block. Use a "_" block from the Values menu to set the value for the winner:
Click NEXT.

When we race on Earth, you can get disqualified and lose the race if you start too early!
I think you can use another function to check for false starts.
You're right! We can copy the determine winner function and change it to check for false starts!
Right-click the determine winner block and select Duplicate to make a copy. Name your new function "false start check".

If a player presses their button early, they lose, so you need to switch the winners in the check false start function:
Click NEXT.

Now that we have these functions, when do we use them?
We want the code to keep checking the buttons, so we will have to use them in loops.
You'll need to replace all the wait blocks in your code with loops.

Did you know that the wait block is actually a loop inside of the Pico? It's a loop that does nothing until the time is up.

Instead, we want our code to check the buttons while we wait.

Grab a repeat for block from the Loops menu. Replace all of your wait blocks with repeat for blocks:
Let's check for false starts in each loop.
Place a false start check block from the Functions menu in each repeat for loop:
Click NEXT.

Okay, our code now checks for false starts, but how do we know who wins?
Oh, shoot! Let's make another loop to check the buttons and decide who the winner is!
Add a repeat while true block to the end of your code. Inside that loop, add a determine winner block:
Click NEXT.

Something is missing....
Yeah - the last loop will just keep looping! It should only loop while there is no winner.
Should the winner variable start with a value of "none"?
Yes! That way, the loop keeps checking the buttons while the winner is "none". Then, when the winner presses their button, the variable will change and the loop will stop looping!
Grab a set winner to block from the Variables menu and place it right under the start block. Use a "_" block to set the value to "none":
Next, delete the true block from the repeat while block.

Grab a __ = __ block from the Logic menu and place it into the repeat while block.

Place a winner block on the left side and a "_" block with a value of "none" on the right side.

Finally, use a print block at the end of the program to print out who the winners are:
Once your code is finished, click NEXT.

Alright, Wheldon Brothers, you're on! The first racers to hit their button after the lights all turn back off wins!
You're on! Let's go! This will be a great warmup for the Intergalactic Championships. Check us out in the Motion Expedition!
Grab a friend and hit START to play!
Keep tweaking your game! Can you rename your winners to your own name? Can you add a third button so 3 people can play at once? Is there a limit to how many buttons you could add?

Click NEXT.

Do you want to know how fast you were going? If so, try the Stopwatch challenge below!
Otherwise, click EXIT to return to the menu and start your next coding challenge.


CHALLENGE MISSION TUTORIAL STEPS

Blueprint

OPEN IN BLUEPRINT VIEWER  DOWNLOAD

Have an different version? Look for more information on the Support Page.

Troubleshooting Tips

  • Is the button press not registering?
    • Look at the Digital View when you press the button while the code runs. If you see no change, push the button into the breadboard forcefully (but carefully) to make sure the leads connect with the rails on the breadboard.
    • Look at the Digital View when you press the button while the code runs. If you see no change, push the button into the breadboard forcefully (but carefully) to make sure the leads connect with the rails on the breadboard.
  • What does “LOW when pulled UP” mean? 
    • This generally refers to pull-up or pull-down resistor circuits. In this case, this allows the signal to be rounded UP to the binary TRUE when the button is pushed, and the circuit is complete.

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