Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator...

5
1 Lesson 7: Cloud Mood Indicator What you will need CloudProfessor (CPF) RGB LED Light Arduino Leonardo Arduino Shield USB cable Learning Expectaons (how learning / progress will be demonstrated) All Download temperature data taken from the CloudProfessor from cloud storage. Most Use variables in their app. Some Explain the benefits and drawbacks of cloud storage. Learning Objecves Use cloud storage to download temperature data. Understand and use variables Understand the benefits and drawbacks of cloud storage. Overview In lesson five, students learned how to upload the value measured by the temperature sensor to the cloud storage. In this lesson, students will learn how to use the temperature data uploaded to cloud in lesson five to control and change the colour of the RGB LED light component. Curriculum Links (Compung PoS) Designs simple algorithms using loops, and selecon i.e. if statements. (AL) Uses logical reasoning to predict outcomes. (AL) Detects and corrects errors i.e. debugging, in algorithms. (AL) Creates programs that implement algorithms to achieve given goals. (AL) Understands that programming bridges the gap between algorithmic soluons and computers. (AB) Computaonal Thinking Concepts: AB = Abstracon; DE = Decomposion; AL = Algorithmic Thinking; EV = Evaluaon; GE = Generalisaon. Lesson 7 Cloud Mood Indicator 1

Transcript of Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator...

Page 1: Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator 1. onnect the power of loudProfessor then press and hold the power button for two

1 Lesson 7: Cloud Mood Indicator

What you will need

• CloudProfessor (CPF)

• RGB LED Light

• Arduino Leonardo

• Arduino Shield

• USB cable

Learning Expectations (how learning / progress will be demonstrated)

All Download temperature data taken from the CloudProfessor from cloud storage.

Most Use variables in their app.

Some Explain the benefits and drawbacks of cloud storage.

Learning Objectives

Use cloud storage to download temperature data.

Understand and use variables

Understand the benefits and drawbacks of cloud storage.

Overview

In lesson five, students learned how to upload the value measured by the temperature sensor to the cloud storage. In this

lesson, students will learn how to use the temperature data uploaded to cloud in lesson five to control and change the

colour of the RGB LED light component.

Curriculum Links (Computing PoS)

Designs simple algorithms using loops, and selection i.e. if statements. (AL)

Uses logical reasoning to predict outcomes. (AL) Detects and corrects errors i.e. debugging, in algorithms. (AL)

Creates programs that implement algorithms to achieve given goals. (AL)

Understands that programming bridges the gap between algorithmic solutions and computers. (AB)

Computational Thinking Concepts: AB = Abstraction; DE = Decomposition; AL = Algorithmic Thinking; EV = Evaluation;

GE = Generalisation.

Lesson 7 Cloud Mood Indicator

1

Page 2: Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator 1. onnect the power of loudProfessor then press and hold the power button for two

2 Lesson 7: Cloud Mood Indicator

1. Connect the power of CloudProfessor then press and hold the power button for two seconds; it will turn on and the

power indicator will light up.

2. Insert the Arduino Shield into Arduino Leonardo and use the USB cable to connect the CloudProfessor with Arduino

Leonardo. Attach the RGB LED light component to port D3.

3. When the CloudProfessor detects the Arduino Leonardo, a notification will appear on your device; click the

notification to launch the Arduino Leonardo APP, and then select the CPF Arduino Blockly app. Click on Lesson 6.

4. Press the execute button to enter the control user interface (UI).

5. Press the edit button to enter the program editing page.

Step-by-step instructions 2

1

2

3

CPF Arduino Blockly app

Edit button

Execute button

Control user interface (UI) Program editing page

Page 3: Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator 1. onnect the power of loudProfessor then press and hold the power button for two

3 Lesson 7: Cloud Mood Indicator

Exploring the code (Blockly)

Let’s explore the code.

1. Title Name Panel Set (Downloading….):

The Title Name Panel Set block displays a message on the screen. In this

example it will display a “Downloading…” message to notify the user that

the program is retrieving data from the cloud.

2. Count with:

The count with block executes the same task repeatedly for a

specified number of times. The number of times the code is

repeated is specified in the ’to’ block (1). In this example, the

code will be repeated 10 times.

3. Set aop_obj to:

The Set aop_obj to block creates a variable called ‘aop_obj and stores the JSON object containing the data

uploaded in the previous lesson.

4. Set celsius to:

The Set celsius to block creates a variable called ‘celsius’ and stores the

contents of ’Value1’ from the JSON object, which in this case contains the

temperature values uploaded in lesson 5 (2).

5. If/else if/else;

The if/else if/else block controls the colour of the RGB

LED based on the temperature value taken from the

downloaded JSON object.

When the temperature is less than 24 degrees, the

RGB LED light will light up blue; when the temperature

is between 24~28 degrees, the RGB LED light will light

up green; when the temperature is between 28~32 degrees, the RGB LED light will light up orange; and when the

temperature is over 32 degrees, the RGB LED light will light up red.

6. RGB LED Setting colour with:

The RGB LED Setting colour with block sets the colour of the RGB

LED. The RGB LED colour can be set to a pre-determined colour (3) or

by manually inputting each of the three red, green and blue values (4).

7. Title Name Panel Set:

The Title Name Panel Set block displays a message on the screen. In this example it will display a “Downloading

finished” message to notify the user that the program has finished retrieving data from the cloud.

3

Try creating your own colours by mixing Red, Green and Blue (There are over ten million light colours). Try

also changing the interval ’Delay time(sec)’ between each colour change.

2

1

3

4

Page 4: Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator 1. onnect the power of loudProfessor then press and hold the power button for two

4 Lesson 7: Cloud Mood Indicator

Exploring the code (JavaScript)

Let’s explore the code.

1. ui.set(“title”, “Downloading….”);

The ui.set(“title”) line displays a message on the screen. In this

example it will display a “Downloading…” message to notify the user that the program is retrieving data from the

cloud.

2. for (index=1; index<=10; index++) {

The for() statement executes the same task repeatedly for a specified

number of times. The number of times the code is repeated is specified

in the first two sections of the for loop (1). In this example, the code will

be repeated 10 times.

3. aop.getStore(storeId);

aop.getStore() downloads the data from the cloud and then converts the

data into JSON format using JSON.parse().

4. celsius = obj.temperature;

celsius = obj.temperature; retrieves the temperature reading downloaded

from the cloud and stores the result in a variable called celsius.

ui.set("temperature sensor", celsius); reads the Celsius value and displays it

on the screen (2).

5. If/else if/else;

The if/else if/else block controls the colour of the RGB LED based on the

temperature value taken from the

downloaded JSON object.

When the temperature is less than 24 degrees, the RGB LED light will light

up blue; when the temperature is between 24~28 degrees, the RGB LED

light will light up green; when the temperature is between 28~32 degrees,

the RGB LED light will light up orange; and when the temperature is over

32 degrees, the RGB LED light will light up red.

6. cpf.set("rgb led");

cpf.set("rgb led"); sets the colour of the RGB LED. The RGB LED colour is set by

manually inputting each of the three red, green and blue values (3).

7. ui.set("title", "Download finish");

The ui.set("title", "Download finish"); line displays a message on the screen. In this example it will display a

“Download finished” message to notify the user that the program has finished retrieving data from the cloud.

3

Try creating your own colours by mixing Red, Green and Blue (There are over ten million light colours). Try

also changing the interval ‘cpf.sleep(2000)’ between each colour change.

2

1

3

Page 5: Lesson 7 - Acer for Education · Lesson 7 loud Mood Indicator 1. 2 Lesson 7: Cloud Mood Indicator 1. onnect the power of loudProfessor then press and hold the power button for two

5 Lesson 7: Cloud Mood Indicator

Extension

Students to take a screenshot of their code and add comments to explain how it works.

Differentiation

To support students, provide step by step guides.

To stretch students ask them to create a flowchart / pseudocode of their code first or code their solution using JavaScript.

Homework

Students to write up a summary of what they’ve learned; students to include screenshots and snippets of their code in

their summary.

Links

Sample weather data from weather stations across the UK: http://weather.lgfl.org.uk

How cloud storage works: http://computer.howstuffworks.com/cloud-computing/cloud-storage.htm

Benefits of data logging: http://www.bbc.co.uk/schools/gcsebitesize/ict/measurecontrol/3dataloggingrev3.shtml

Disclaimer: Use these sites at your own risk. Acer is not responsible for the content of external Internet sites. We

recommend that you check the suitability of any recommended websites links before giving them to students.

4

5

6

7