CyberPi: Strength Meter
In this lesson, students will create a fun game with the CyberPi where the player shakes the CyberPi for ten seconds. The students will program the game to keep score of how many times the shaking strength is greater than 50.

Lesson
Overview
Description
In this lesson, students will create a fun game with the CyberPi where the player shakes the CyberPi for ten seconds. The students will program the game to keep score of how many times the shaking strength is greater than 50.
Objectives
Write a program in mBlock that keeps score.
Write a program that executes actions for a specified amount of time.
Display text on the CyberPi display.
Before the Lesson
Preparation
For the teacher and students:
Computer with mBlock 5 installed from here: https://www.mblock.cc/en/download/ or mBlock Web version
CyberPi with USB-C cable
Pocket shield (optional)
Example program(s): CyberPi – Lesson 8 – Strength Meter
Review
Warm-Up
Variable Review
Review variables with the class and explain how variables can be used to keep track of a score in an mBlock project. Review with students how to create a variable, set a variable and change a variable in mBlock.
Direct Instruction
Tour of mBlock 5
1. Open the mBlock software or mBlock 5 Web version.
2. Introduce students to the following key areas of the software interface:


Connect the CyberPi
3. Plug the CyberPi into the computer using the included cable. The CyberPi should boot up and the screen will display either the last program uploaded or the Home menu.
4. On the "Devices" tab in mBlock, click the "Add" button. Select CyberPi and click "Ok".
5. Click the "Connect" button. Then, select the USB port and click "Connect".

6. If connected successfully, the button will change to "Disconnect".

Guided Practice
Hands-On
Detecting Strength
1. Review the following challenge and pseudocode with the students:

2. Open the mBlock 5 software or mBlock 5 Web version. Add the CyberPi in the Devices tab and connect in Live mode.
3. Introduce students to the following new blocks:

4. Instruct students to build the following scripts and test the program to observe the shaking strength values:

Keeping Score
5. Make a variable named score and leave For all sprites selected.
6. Instruct students to add the following scripts to the program:

7. Now that the CyberPi is keeping track of the score, add the following scripts to display the score on the screen with button A is pressed:

8. Have students play the game and see how many points they can earn.
Independent Practice
Try It
Creating Strength Meter 2.0
1. With a simple version of a Strength Meter game created, there are many improvements that can be added to the program. Have students identify areas of improvement for this design. Some ideas for improvement include:
Use the LED Strip to inform the user when the game is running.
Add a sound effect each time a point is earned.
Add a sound effect when time runs out.
Add a title and instructions.
Use the joystick and a variable to change the difficulty of the game (i.e., shaking strength for easy is 30, medium is 50 and hard is 70).
2. Have students develop a plan and pseudocode for the improvements they would like to add to their project.
3. Have students create the Strength Meter 2.0 using their pseudocode as a guide.
Extension
Have students program the LEDs to progressively light up based on the strength (see example).
Have students program a 2-player game where it tracks a score for both players, compares the scores and declares a winner.
Wrap Up
Wrap-Up & Quick Check
Motion Sensing
The CyberPi has a 3-axis gyroscope and a 3-axis accelerometer which detects motion, acceleration and vibration. The shaking strength block uses this component to determine how strong the CyberPi is being shaken. Have students brainstorm a list of devices they use that use a gyroscope. Some examples may include:
Mobile phones change the screen orientation based on device rotation.
Screens on mobile phones light up when the device is picked up.
Video game controllers detect motion.
Robotic vacuums detect if they have fallen or tipped over.
Downloadable Material
Example Program
Educational Standards
CSTA
CSTA
2-CS-02: Design projects that combine hardware and software components to collect and exchange data.
2-AP-11: Create clearly named variables that represent different data types and perform operations on their values.
Alberta - Grade 6-8 - CTF
Grade 6-8
CTF
- Planning, creating, appraising and communicating in response to challenges.
- Working independently and with others while exploring careers and technology.
British Columbia - Grade 6-8 - ADST
Grade 6-7
ADST
• Generate potential ideas and add to others’ ideas
• Identify and evaluate the skills and skill levels needed, individually or as a group, in relation to a specific task, and develop them as needed
• Select, and as needed learn about, appropriate tools and technologies to extend their capability to complete a task
Grade 8
ADST
• Generate potential ideas and add to others’ ideas
• Make a plan for production that includes key stages, and carry it out, making changes as needed
• Identify and evaluate the skills and skill levels needed, individually or as a group, in relation to a specific task, and develop them as needed
• Select, and as needed learn about, appropriate tools and technologies to extend their capability to complete a task
Manitoba - Grade 6-8 - Science
Grade 6
Science (Overall Skills and Attitudes)
6-0-4a: Carry out procedures that comprise a fair test. Include: controlling variables; repeating measurements to increase accuracy and reliability.
6-0-4c: Work cooperatively with group members to carry out a plan, and troubleshoot problems as they arise.
Grade 7
Science (Overall Skills and Attitudes)
7-0-4a: Carry out procedures that comprise a fair test. Include: controlling variables, repeating experiments to increase accuracy and reliability
7-0-4c: Work cooperatively with team members to carry out a plan, and troubleshoot problems as they arise.
Grade 8
Science (Overall Skills and Attitudes)
8-0-4a: Carry out procedures that comprise a fair test. Include: controlling variables, repeating experiments to increase accuracy and reliability
8-0-4c: Work cooperatively with team members to carry out a plan, and troubleshoot problems as they arise.
New Brunswick - Grade 6-8 - Science
Grade 6-8
Science (Attitude Outcome)
425: show a continuing curiosity and interest in a broad scope of science-related fields and issues
430: persist in seeking answers to difficult questions and solutions to difficult problems
431: work collaboratively in carrying out investigations, as well as in generating and evaluating ideas
Newfoundland & Labrador - Grade 6-8 - Science
Grade 6-8
Science
GCO: Skills - Students will develop the skills required for scientific and technological inquiry, for solving problems, for communicating scientific ideas and results, for working collaboratively, and for making informed decisions.
Nova Scotia - Grade 6-8 - ICT & Mathematics
Grade 6
Mathematics
N09 Students will be expected to explain and apply the order of operations, excluding exponents, with and without technology (limited to whole numbers).
Performance Indicators:
N09.01 Demonstrate and explain, with examples, why there is a need to have a standardized order of operations.
N09.02 Apply the order of operations to solve multi-step problems with or without technology (e.g., computer, calculator).
PR03 Students will be expected to represent generalizations arising from number relationships using equations with letter variables.
Performance Indicators:
SCO PR03 Students will be expected to represent generalizations arising from number relationships using equations with letter variables. [C, CN, PS, R, V]
PR03.01 Write and explain the formula for finding the perimeter of any regular polygon.
PR03.02 Write and explain the formula for finding the area of any given rectangle.
PR03.03 Develop and justify equations using letter variables that illustrate the commutative property of addition and multiplication (e.g., a + b = b + a or a × b = b × a).
PR03.04 Describe the relationship in a given table using a mathematical expression.
PR03.05 Represent a pattern rule using a simple mathematical expression, such as 4d or 2n + 1.
ICT
P2: Students will be expected to use digital tools to develop ideas and original works in innovative ways.
TOC1: Students will be expected to
* safely use many forms of current technology for learning with growing competence
* demonstrate conceptual understanding of how information and communication technology, digital tools, and authorized networks support their learning
* use terminology related to information and communication technology
Grade 7
Mathematics
PR05 Students will be expected to evaluate an expression given the value of the variable(s).
Performance Indicator:
PR05.01 Substitute a value for an unknown in a given expression and evaluate the expression.
Technology
GCO1: Students will be expected to design, develop, evaluate, and articulate technological solutions
GCO2: Students will be expected to operate and manage technological systems
Grade 8
Technology
GCO1: Students will be expected to design, develop, evaluate, and articulate technological solutions
GCO2: Students will be expected to operate and manage technological systems
Ontario - Grade 6-8 - Mathematics
Grade 6
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves conditional statements and other control structures
Grade 7
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves events influenced by a defined count and/or sub-program and other control structures
Grade 8
Mathematics
Algebra
C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves the analysis of data in order to inform and communicate decisions
Prince Edward Island - Grade 6-8 - Science
Grade 6-8
Science
GCO: Skills - Students will develop the skills required for scientific and technological inquiry, for solving problems, for communicating scientific ideas and results, for working collaboratively, and for making informed decisions.
Quebec - Grade 6-8 - Science
Grade 6-8
Science (Strategies)
Exploring various ways of solving the problem
Exchanging information
Comparing different possible explanations for or solutions to a problem in order to assess them (e.g. full-group discussion)
Saskatchewan - Grade 6-8 - Science
Grade 6-8
Science (Goals)
Develop Scientific and Technological Skills – Students will develop the skills required for scientific and technological inquiry, problem solving, and communicating; for working collaboratively; and for making informed decisions.
