5
1 Lesson 2: Remote Controlled Fan What you will need CloudProfessor (CPF) White LED light Fan motor Arduino Leonardo Arduino Shield USB cable Learning Expectaons (how learning / progress will be demonstrated) All Use sequences of instrucons. Most Explain how their app works. Some Use logical reasoning to detect errors in their algorithms. Learning Objecves Design and create an app which uses sequence, selecon, repeon and variables Program, debug and refine the code for their app Detect and correct errors in their app Overview In this introductory lesson to the CloudProfessor, students will explore the basics of wring algorithms using the Blockly editor. Students will explore exisng code and use what they learnt to develop their own programs for the CloudProfessor to create a remotely controlled fan and working Zoetrope. 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 2 Remote Controlled Fan 1

Lesson 2 - Acer for Education · notification to launch the Arduino Leonardo APP, and then select the PF Arduino lockly app. lick on Lesson 2. 4. Press the execute button to enter

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lesson 2 - Acer for Education · notification to launch the Arduino Leonardo APP, and then select the PF Arduino lockly app. lick on Lesson 2. 4. Press the execute button to enter

1 Lesson 2: Remote Controlled Fan

What you will need

• CloudProfessor (CPF)

• White LED light

• Fan motor

• Arduino Leonardo

• Arduino Shield

• USB cable

Learning Expectations (how learning / progress will be demonstrated)

All Use sequences of instructions.

Most Explain how their app works.

Some Use logical reasoning to detect errors in their algorithms.

Learning Objectives

Design and create an app which uses sequence, selection, repetition and variables

Program, debug and refine the code for their app

Detect and correct errors in their app

Overview

In this introductory lesson to the CloudProfessor, students will explore the basics of writing algorithms using the Blockly

editor. Students will explore existing code and use what they learnt to develop their own programs for the CloudProfessor

to create a remotely controlled fan and working Zoetrope.

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 2 Remote Controlled Fan

1

Page 2: Lesson 2 - Acer for Education · notification to launch the Arduino Leonardo APP, and then select the PF Arduino lockly app. lick on Lesson 2. 4. Press the execute button to enter

2 Lesson 2: Remote Controlled Fan

Step-by-step instructions

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 White LED light to port D2 and the Fan motor 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 2.

4. Press the execute button to enter the control user interface (UI). The UI can be used to adjust the speed of the fan.

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

2

1

2

3

CPF Arduino Blockly app

Edit button

Execute button

Control user interface (UI) Program editing page

Page 3: Lesson 2 - Acer for Education · notification to launch the Arduino Leonardo APP, and then select the PF Arduino lockly app. lick on Lesson 2. 4. Press the execute button to enter

3 Lesson 2: Remote Controlled Fan

Exploring the code (Blockly)

Let’s explore the code.

1. White LED Get setting value:

The white LED Get settings value block reads the status of the white light on the

interface (on: 1, off: 0)

2. Fan Get setting speed:

The Fan Get setting speed returns the speed value taken from the program control user interface (UI). In this

example, when the white LED light component is on, the rotation speed of the fan motor can be controlled

manually. When the white LED light component is off, the fan motor will stop. The fan motor component control

item ranges from 0 to 255.

3. Fan Control Set Speed:

The Fan Control Set Speed block sets the speed of the Fan.

The speed can be either set manually (2) or controlled by the program UI (1)

4. If / else:

The if / else block is used to conditionally run code

depending on whether a Boolean condition is true or false.

In this example, when the LED light component is on (Get

setting value = ON), the fan motor will start rotating at the

speed set by the user (Fan Get setting speed); or else

(else), if the LED light

component is off, the fan motor will automatically stop

turning.

5. Set CPF control request:

Finally, the Set CPF control request block at the end of the program tells the program to run the code from the

beginning again. The program will continuously repeat until the user closes the app or stops the program manually.

3

Try replacing Fan Get setting speed with a value such as ‘100’ or ‘200’. Experiment with different fan speeds

until you find the optimum speed. Use the attached template to turn your fan into a Zoetrope.

1

2

Page 4: Lesson 2 - Acer for Education · notification to launch the Arduino Leonardo APP, and then select the PF Arduino lockly app. lick on Lesson 2. 4. Press the execute button to enter

4 Lesson 2: Remote Controlled Fan

Exploring the code (JavaScript)

Let’s explore the code.

1. var power = ui.get(“white led”);

The var power = ui.get(“white led”); statement reads the status of the white

light on the UI (on: 1, off: 0) and stores the result in a variable called power.

cpf.set(“ white led”, power); reads the value taken from the UI and turns the

while LED component on or off accordingly.

2. var speed = ui.get(“fan”);

The var speed = ui.get(“fan”); statement returns the speed value taken from the program control user interface

(UI). In this example, when the white LED light component is on, the rotation speed of the fan motor can be

controlled manually. When the white LED light component is off, the fan motor will stop. The fan motor component

control item ranges from 0 to 255.

3. cpf.set(“fan”, speed);

cpf.set(“fan”, speed); sets the speed of the Fan. The speed can be either set

manually (2) or controlled by the program UI (1)

4. If / else:

The if / else statement is used to conditionally run code depending on whether

a Boolean condition is true or false. In this example, when the LED light component

is on (ui.get(“white led”) = ON), the fan motor will start rotating at the speed set by

the user (cpf.set(“fan”, speed)); or else (else), if the LED light

component is off, the fan motor will automatically stop turning: cpf.set(“fan”, 0);

5. cpf.repeat();

Finally, the cpf.repeat(); statement at the end of the program tells the program to run the code from the

beginning again. The program will continuously repeat until the user closes the app or stops the program manually.

3

Try replacing Fan Get setting speed with a value such as ‘100’ or ‘200’. Experiment with different fan speeds

until you find the optimum speed. Use the attached template to turn your fan into a Zoetrope.

1

2

Page 5: Lesson 2 - Acer for Education · notification to launch the Arduino Leonardo APP, and then select the PF Arduino lockly app. lick on Lesson 2. 4. Press the execute button to enter

5 Lesson 2: Remote Controlled Fan

Extension

Students to create a remotely controlled Zoetrope. Using their mobile device, students will be able to manually adjust the

speed (frame rate) of the animation inside of the Zoetrope. Students can use the attached template to create their

Zoetrope. Students can use a combination of Sellotape, plastercine or blue tack to attach their Zoetrope to their motor.

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

How a Zoetrope works: http://www.randommotion.com/html/zoe.html

Zoetrope definition: https://en.wikipedia.org/wiki/Zoetrope

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