PIPER MAKE

EDUCATOR GUIDES


YOU ARE HERE

Base expedition

Mission 7 of 13

Base expedition: Mission 7 of 14

Tally


Intermediate

1 hour

Grades 3 - 8

MISSION OBJECTIVE

Learn to build and code a circuit that can count how many times you press a button.

In this project, students will build a counter using a variable. The counter records how many times a button is pressed. Tally represents a common way that a score is kept in a video game.

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

MISSION RESOURCES

Learning Goals

  1. Students will build a tactile button that completes a circuit when pressed.
  2. Students will use variables and loops to create a program that records the number of times someone pushes the button.
  3. Students will integrate skills related to knowledge about variables, conditionals, and debugging in the same project.
I WILL BE ABLE TO...
  • Build a button that completes a circuit when pushed
  • Use variables and loops to record the number of times I press the button

Learning Activities

ELA Extension: Tally Report Writing

  • Pair students up or allow them to work independently based on grade level and writing readiness. Students will collect real-world data using the Tally Counter code and write an informative or persuasive report based on their findings.
  • Begin by choosing a question to investigate as a class or individually (e.g., “Which snack is most popular?” or “Do more students prefer cats or dogs?”).
  • Students will collect data using the button press tally counter or traditional tally marks. They organize their data into a table or chart.
  • Students then write a 1-, 3-, or 5-paragraph report that includes:
    • An introduction to the question and its purpose
    • A summary and interpretation of the data (e.g., “Out of 20 students, 12 chose pizza.”)
    • A reflection on what the results might mean or why they occurred
    • (Optional) A persuasive paragraph using the data to support an argument (e.g., “We should serve more pizza because it’s clearly the favorite.”)

Bonus vocabulary words to include: tally, data, input, count, analyze, record

EXTENSION: Create a Data Detectives Wall or digital gallery where students post charts, graphs, and reports alongside visuals or code snippets.


ELD Extension: Partner Tally Survey
  • Pair students so that each English Learner (EL) is working with a fluent or higher-level EL.
  • Students will begin by practicing simple survey questions with a partner using sentence starters:
    • "Do you like ___ or ___?"
    • "Which one do you choose?"
  • Provide visuals and a scaffolded tally chart for support.
  • Each student will then tally answers from 5–10 classmates using the button press counter or paper. They will practice saying their results using complete sentences:
    • "I asked 8 students. 5 chose __. 3 chose __."
    • Students will retell and present their findings with a partner or small group using sentence frames:
    • "Most people chose __."
    • "Only __ people chose __."
    • "The total was __."
EXTENSION: Optional Skit
Pairs can create a fun news-style interview using their results.
Example: "Back to you, Pip! 10 students voted for mangoes today!"

Math Extension: Tally, Graph, and Reflect
  • Pair students together or assign groups based on class needs.
  • Begin by brainstorming survey questions that can be answered with tally data
  • (e.g., "How many people wear glasses?" or "How many smiley faces are in your notebook?"). Assign different groups to different questions to add variety.
  • Students collect data using the Tally Counter or tally marks in groups of five. They organize their data in a chart and create a bar graph or line plot to visualize results.
  • Students will then calculate and discuss:
    • The total count
    • The mode (most common response)
    • Any patterns or surprising results
  • Use class discussion prompts such as:
    • "What surprised you about the results?"
    • "How would the data change if we surveyed more people?"
    • "What’s another way to show this data?"

EXTENSION CHALLENGE:
Turn the lesson into a Math Scavenger Hunt—students tally real-life items around the room or school (e.g., red shirts, high-fives, blue backpacks). Then organize and analyze the collected data as a class.

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

Tally

The ignition in Piperbot's spaceship isn't working! Think Pip can turn the key more times in 10 seconds to kick the spaceship into gear?

I bet I can hit my button more times in 10 seconds than Piperbot can! Who knows, maybe it'll get his spaceship working?
Pshh, no way you can hit that button more times than me! Time to get counting!
Let's build a simple button and learn how to write code to count the number of times we push the button to tally our score.

Ready? Count us in!

Click NEXT.

Let's start by grabbing our pieces! Remember you can see those pieces better by hitting that expand icon in the top right there.
Time to build our first circuit! Let's plug one of the wires into into the GP7 pin and the other into a GROUND pin and add our Pushbutton like this!
Once your circuit is built, click NEXT.

Okay Pip, now how are we going to write code that keeps track of how many times the button is pressed?
Technically I guess we want some component that changes value every time we hit the button right? If only there was a code component like that...
What code component changes value based on code parameters?
Variable
Logic Gates
Function
Loop

A variable can change values! Since our number changes every time you press the button, you'll need a variable.
Grab a Start block from the Chip menu and drag it out onto the workspace.
A variable stores a value, like the number of button presses. Click the Variables menu to open it, and then click the Create Variable... button. Name your new variable "press count".
Hmm but we want to make sure our count variable starts at 0, right?
After you create your variable, some new blocks will be available in the Variables menu. Grab the set press count block and connect it below the start block.

Next, we want our count variable to start at zero, so grab a 0 block from the Values menu and place it in the input of the set press count block:
Click NEXT.

We want to be able to see the value of the variable as it changes, so we have an ongoing tally of me beating you, right?
To display in the Console, add a print block. Remove the "_" block and drag it to the trash. Then, from the Variables menu, drag a press count block into the print block. Your code should look like this:
Click on the CONSOLE tab at the bottom of the workspace to open it. Click START to see the variable value printed.

Click NEXT.

Okay awesome, now we're counting, but I'm pressing this button and nothing is being detected!
Check out your Chip menu. You'll see a block that looks like the one below. Make sure the right pin is selected.
Click NEXT.

Hmm but right now our code will just stop if we hit the button once. We want it to keep detecting multiple presses!
Let's loop it!
Grab a repeat while true block from the Loops menu and connect it between the set press count block and the print block.

Next, drag a wait until block from the Logic menu and place it into the repeat while true block. Do this one more time so that you have two wait until blocks. Then, grab an is pin block from the Chip menu and place it into the input of the wait until block. Change the pin on the is pin block to 7, since that is what our button is connected to. Do this again so that there is an is pin 7 block in both wait until blocks.

Finally, drag the print block from the bottom of your program and place it into the repeat while true block:
Click START. Now, try pressing the button on your Breadboard.

Once you've tried out your program, click STOP. Then, click NEXT.

But right now, our press count will just keep showing 0 since nothing is changing the variable value. We want this variable to change every time a press is detected.
Grab a change press count from the Variables menu block and place it right above the print to block. This will make your program add 1 to the press count variable every time you press the button on your Breadboard.
Let's try it out! Make sure the CONSOLE tab is open and then click START.
1
2
3
4
5
Once you've tried it out, click STOP. Then, click NEXT.

Okay, we've got our little counter, now how do we make the tally stop at 10 seconds?
Hmm it kind of sounds like we want that pin reading to only happen while the time is less than 10 seconds?
To create a timer that stops at 10 seconds, we want the chip clock value to be less than or equal to 10.

Drag out a _ = _ block from the Logic menu and set the condition to chip clock ≤ 10.
Sweet! Now if I hit START, I can hit my button as many times as I can and I'll get a tally of me beating Piperbot!

Ooh you know what would be fun? If our program played a little sound when we got to our favorite number!
My favorite number is 6, can we do it with that??
Grab an if _ = _ do block from the Logic menu and connect it right below the print block in your program. Then, grab a press count block from the Variables menu and place it into the first input of the _ = _ block. Next, grab a 0 block from the Values menu and place it into the second input of the _ = _ block. Finally, change the 0 to a 6:
Click NEXT.

First, grab a play sound block from the Sounds menu and place it into the empty if do block.
Ooh which sound do we want to play? Let's click the Sounds menu and choose a sound to place in the play sound block.
Grab one of the sound blocks from the Sounds menu and place it into the input of the play sound block.
Let's try it out! Make sure the CONSOLE tab is open, and then click START.
Did your program play a sound when you clicked the button 6 times?
Go ahead and click STOP, then click NEXT.

We did it! Pip sure gives me a run for my money with how quick that little Martian mouse can hit that button... Maybe Pip can actually get my spaceship running...
Cool! Where are running tallies important in the tech you deal with everyday? How could you give Piperbot or Pip an advantage in their game of quick button presses?
Click EXIT to return to other coding tutorials.

Blueprint

OPEN IN BLUEPRINT VIEWER  DOWNLOAD

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

Troubleshooting Tips

  • Are the console numbers failing to change when you click the button?
    • Ensure that your code includes the line to add 1 to the number you have in the console.
    • Ensure that you’ve plugged the wires into the right GPIO. Look at the Digital View to see which pin you’re affecting.

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