CyberPi: Noise Detector
In this lesson students will gain a basic understanding of the characteristics and types of data, and the importance of data in everyday life. Students will use sensors to retrieve data and display data on the screen while identifying different types of data and their functions.

Lesson
Overview
Description
In this lesson students will gain a basic understanding of the characteristics and types of data, and the importance of data in everyday life. Students will use sensors to retrieve data and display data on the screen while identifying different types of data and their functions.
Objectives
Identify the basic characteristics and types of data.
Clarify the importance and common use of data in everyday life.
Use sensors to retrieve data, and display data on the screen.
Write programs to create a noise detector.
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
Wi-Fi connection to student devices for IoT connectivity
One CyberPi’s with USB-C cable
Pocket shield (optional)
Example program(s): CyberPi – Lesson 1 - Noise Detector
For students:
Proficiency in block-based coding
Basic knowledge of sensors
Review
Warm Up
Objective:
Have students do an in-class survey and collect data, preparing them for the later session about what data is.
Procedures:
Hand out pens and paper to students. Have students work in pairs. Ask them to investigate the topic by asking classmates on the following questions:
(1) Where would you like to spend your weekends most?
(2) How many times do you go to the library per month?
(3) What month does your birthday fall?
Give students 1 minute to work on their survey.
Pick 2 or 3 students to share their survey.
Ask: What's your first thought when you hear "data"? What is data?
Explain:
Types of data: The answers to the three questions above could all be considered data. Data is distinct information that is formatted in a special way. Birthday, hobby, height, weight and others. All these are data. Data exists in a variety of forms, like images, sounds, texts, symbols and more.
Use of data: Data could be used to convey messages, e.g. queue management system, weather report, bus arrival notification...
Summary: Data helps us solve and organize problems in many ways.
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
Objective:
Introduce a scenario where a noise detector could be used, and have students think about noise pollution in their life.
Have students brainstorm possible solutions to deal with the data they've collected, and design features they want.
Procedures:
Discuss a scenario where noises are annoying.
Ask: If you’re on a bus and someone is talking aloud, how will you feel?
Ask: Suppose we now have a device that's monitoring sounds around. To reduce some noises like this, how should we design the device? What features must the device have? You have 1 minute to discuss with your partner.
Pick 2 students to share their thoughts.
Categorize the features based on students’ discussion
Show students how the noise detector works.
Work with students to analyze what features a noise detector must have, and draw a mind map.

Independent Practice
Try It
Objective:
Give students the freedom to explore further so that they can enhance their programming skills.
Procedures:
Show students where these modules are on CyberPi: LED Screen, Buttons, Joystick, Switch, Sensors, LED Indicators.
Teach students how to start their CyberPi and connect the device to mBlock.
Add the device CyberPi in mBlock, and start programming it.
Display sound volume:
Use CyberPi's sound sensor to detect sound volume. Tick the coding block below to display volume on the stage in mBlock.

To display sound volume on CyberPi's screen, you need to use the following three blocks

Program CyberPi to display sound volume:

NOTE:
Remove all the existing content on the screen at the very beginning to make sure the new content is clearly displayed.
Have students use the device to directly retrieve volume and observe what happens.
Explain: The device has an in-built sensor to detect sound volume in real time, so the volume value retrieved will keep fluctuating all the time. As a result, you may find it much harder to see an exact volume value on the screen. To slow down the changes of value, you can set up a variable named "volume" to store the volume value retrieved.
Make decisions based on the sound volume:
Decide whether to give alerts or not.
Use the block broadcast () and wait to send alerts.

Relying on the mind map, program CyberPi to make decisions based on volume:

NOTE:
The example program above uses "40" as a threshold. But students can change the threshold to another value as they'd like to.
Define the alerts and standby
Based on what we observed, CyberPi will give the following alerts when the volume is too high.
LEDs blink red;
The screen displays the text "Please be quiet".
Program CyberPi to give alerts:
LEDs blink red:
Use the blocks below:

Program CyberPi to display the warning text "Please be quiet" on its screen:

Standby status:
LEDs turn off;
Warning text disappears.
Program CyberPi to define its standby status:

NOTE:
The program already includes a coding block for clearing the screen, so we don't need to clear the screen again here.
Extension
Have students explore different Display blocks
They can try:
Changing the font size
Creating their own colours
Display different colours depending on how loud the volume detected is
Use the graphing block to show changes in volume
Wrap Up
Wrap-Up & Quick Check
Objective:
Have students think of any situation in which they will use their project. Make them rethink about incivility in public space and the application of data in everyday life.
Procedures:
Pick 1 or 2 students to showcase their noise detector.
Where do we need to use noise detectors? Where and when should we be careful about our volume? Ask students to have a discussion.
Ask: Can you think of any other applications of data in daily life? What data are you familiar with in your everyday life?
Downloadable Material
Example Program
Educational Standards
ISTE
ISTE
5b: Students collect data or identify relevant data sets, use digital tools to analyze them, and represent data in various ways to facilitate problem-solving and decision-making.
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 7-8 - CTF & Mathematics
Grade 7-8
CTF
Planning, creating, appraising and communicating in response to challenges.
Working independently and with others while exploring careers and technology
Mathematics
GCO: Collect, display and analyze data to solve problems.
British Columbia - Grade 7-8 - ADST
Grade 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 7-8 - Mathematics
Grade 7-8
Mathematics
GCO: Collect, display, and analyze data to solve problems.
Newfoundland & Labrador - Grade 7-8 - Mathematics
Grade 7-8
Mathematics
GCO: Collect, display, and analyze data to solve problems.
Nova Scotia - Grade 7-8 - Technology & Mathematics
Grade 7
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
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.
PR02 Students will be expected to create a table of values from a linear relation, graph the table of values, and analyze the graph to draw conclusions and solve problems.
Performance Indicators:
PR02.01 Create a table of values for a given linear relation by substituting values for the variable.
PR02.02 Create a table of values, using a linear relation, and graph the table of values (limited to discrete elements).
PR02.03 Sketch the graph from a table of values created for a given linear relation, and describe the patterns found in the graph to draw conclusions (e.g., graph the relationship between n and 2n + 3).
PR02.04 Describe, using everyday language, in spoken or written form, the relationship shown on a graph to solve problems.
PR02.05 Match a given set of linear relations to a set of graphs.
PR02.06 Match a given set of graphs to a given set of linear relations.
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
Mathematics
PR01 Students will be expected to graph and analyze two-variable linear relations.
Performance Indicators:
PR01.01 Determine the missing value in an ordered pair for a given equation.
PR01.02 Create a table of values by substituting values for a variable in the equation of a given linear relation.
PR01.03 Construct a graph from the equation of a given linear relation (limited to discrete data).
PR01.04 Describe the relationship between the variables of a given graph.
SP01 Students will be expected to critique ways in which data is presented.
Performance Indicators:
SP01.01 Compare information provided for the same data set by a given set of graphs, including circle graphs, line graphs, bar graphs, and pictographs, to determine the strengths and limitations of each graph.
SP01.02 Identify the advantages and disadvantages of different graphs, including circle graphs, line graphs, bar graphs, and pictographs, in representing a given set of data.
SP01.03 Justify the choice of a graphical representation for a given situation and its corresponding data set.
SP01.04 Explain how the format of a given graph, such as the size of the intervals, the width of the bars, and the visual representation, may lead to misinterpretation of the data.
SP01.05 Explain how a given formatting choice could misrepresent the data.
SP01.06 Identify conclusions that are inconsistent with a given data set or graph, and explain the misinterpretation.
Ontario - Grade 7-8 - Mathematics
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
Data
D1.2 collect qualitative data and discrete and continuous quantitate data to answer questions of interest, and organize the sets of data as appropriate, including using percentages
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 7-8 - Mathematics
Grade 7-8
Mathematics
GCO: Collect, display, and analyze data to solve problems.
Quebec - Grade 7-8 - Mathematics
Grade 7-8
Mathematics
Formulates questions for a survey (based on age-appropriate topics, students’ language level, etc.)
