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

Project Extra

PiperCode Project Extra

El Pangolin (Simon)


Advanced

60 Mins

Grades 3 - 8

Look for the graphic above
to launch the project
INTRODUCTION

Design a game to play against one another!

In this project, students design a game of skill that they may play against each other. Similar to the game of Simon, this head-to-head game will have one player press a sequence of five button clicks and the second player must repeat the same sequence. If done correctly, a winner sound will play OR a loser sound will play if not done correctly. The step-by-step instructions in the tutorial guide students through the process of building the circuit and writing the code.

PROJECT MATERIALS

Piper Computer Kit
6 Wires (2 green, 2 red, 2 blue)
3 Buttons

PROJECT RESOURCES

Concepts

In this project, students will learn to use lists, another key skill for programming. This is the most complex project in Piper Code combining all of the key skills learned through the previous projects (except events) including functions, procedures, variables, conditionals, sounds, debug and states.

Troubleshooting Tips

  • Students will be challenged with the instructions of building code, testing it with the print blocks, then removing the print blocks. With the print blocks, you are printing to the console to make sure that your code is working! Once the testing is complete, make sure they remove the print blocks. this is very complex code, and can take a while to get right and to debug.
  • There are 3 three separate groupings of code blocks (each is a function). Make sure students understand that each must be built separately and they work together to run the game. Each function is given a unique name (recordButtonPresses and testWin).
  • The concept of lists is introduced. A list is a storage place similar to variables, but it is for multiple items. In this example, the list is named ‘simon’ with the code block ‘set simon to create empty list’. This is like a list used in math class and you can think of it as items separated by commas.
  • A variable name ‘count’ is used to determine the position of the item in the list period to go from one item to the next, count is incriminated with the code block set count to count plus one. A value is stored in the list with the code block in list Simon set hashtag count as green. If the value stored in count is 2, then the second item in the list would be green. Notice that the hashtag in front of count in this block, it is important as it indicates that count is being used for the position in the list.
  • Two lists are actually being created. One is storing the button presses for player one and the other is storing the button presses for player two. This happens with the code blocks ‘set player1 to recordbuttonpresses’ and ‘set player 2 to recordbuttonpresses’.
  • Items are retrieved and compared from the list in the testWin function. This function is run with two variables, x & y; x is the list created for player 1 and y is the list created for player 2. The code ‘in list x get #1’ is retrieving the first item in list x. A comparison is made with the full block if (in list x get #1) Not Equal to (in list Y get #1) return false. This can be interpreted as if the first item in list x is not equal to the first item in list y, then exit this function and send ‘false’ back to the code block that ran testWin. When all 5 positions are compared, if they are all equal, then send ‘true’ back to the code block that ran testWin.
  • In the Main function, the code block ‘If testWin with x player 1, y player 2’ runs the testWin function and receives back a value of either true or false. That value is used to determine whether the buzzer sounds indicating no match, or the musical notes are played indicating a good match.

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 Set up the stuff

Plug in the three buttons and match the wires with pins: 22 and 24, 30 and 32, 38 and 40.

GPIO Setup Button Pins: 22, 24
Button Pins: 30, 32
Button Pins: 38, 40

Step 2 Begin the recordButtonPresses function

Inside the recordButtonPresses function, set count to 0 and simon to an empty list.

Step 3 Start the listening button loop

Add a Repeat While block to repeat endlessly while count is less than 5.

Step 4 Create If statements

Create 3 If statements, one checking if pin 22 is on, one checking if pin 32 is on, and one checking if pin 38 is on.

Step 5 Add unique button sounds

Play a unique sound inside each If statement.

Step 6 Increase the count variable

Each If statement should set count to count + 1.

Step 7 Set list at count to a color

Set the list simon to "blue", "red", or "green" at # "count".

Step 8 Return the list of buttons at the end

At the end of recordButtonPresses, be sure to return the variable simon.

Step 9 Test the function

Add prints at the end of each If statement with their respective colors.

Step 10 View Console Tab

Click the Settings tab and enable the console.

Step 11 Add the function to the Start block

Call the function by adding it under the Start block inside a Repeat Forever block.

Step 12 Press Start and check the buttons

Select Start, then press all the buttons to ensure all the wires are hooked up correctly.

Step 13 Clear out the test code

Be sure to clean up all the test code before continuing.

Step 14 Start the testWin function

Inside the testWin function, add 5 If statements which return false. At the end of the function, return true.

Step 15 Fill out the testWin If-statements

Each If statement should check elements of the same position from each list. If they are not equal, return false.

Step 16 Start the main game loop under Start

Under the Start block use a Pin On/Off block to set pins 24 and 40 to OFF, then add a Repeat Forever block.

Step 17 Get both players' input

Set two variables, player1 and player2 to recordButtonPresses. Play a sound for each player.

Step 18 Check the two inputs against each other

Use an If/Else block to check testWin against player1 and player2. Play a sound depending on the result!

Step 19 Challenge someone to a game of Simon!

Press Start and have fun!

Completed!