1 Lesson 20: Project
What you will need
• CloudProfessor (CPF)
• Arduino Leonardo
• Arduino Shield
• USB cable
• LED 101 light
• RGB LED Light
Learning Expectations (how learning / progress will be demonstrated)
All Create a plan for their project using flow diagrams or pseudocode.
Most Create a fully working app using either Blockly or JavaScript.
Some Use logical reasoning to detect errors in their app.
Learning Objectives
Produce algorithms in pseudocode or flow diagrams to solve a problem.
Design and create an app which uses sequence, selection, repetition and variables.
Program, debug and refine the code for an app.
Overview
In this lesson, students will use what they have learnt in the previous lessons to design and implement their own Internet of
Things (IoT) project.
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 20 Project
1 • White LED
• Light sensor
• Temperature sensor
• Fan motor
• Servo / Buzzer / PIR /
Button / LCD backlight
2 Lesson 20: Project
Code recap (Blockly)
Let’s explore some of the code used in the previous lessons.
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. 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, the light will turn on if the light level is less
than 500.
3. Count with:
The count with block executes the same task repeatedly for a specified num-
ber 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.
4. Light Get Value:
The Light Get Value block returns the value of the light sensor (Returns a numeric value based on the brightness level of
the environment).
5. RGB LED Setting colour with:
The RGB LED Setting colour with block sets the colour of the attached RGB LED.
The colour can be either set manually (3) or controlled by the program UI (2).
6. Set date to:
The Set date to block creates a variable called ‘date’ and stores the current
date/time.
7. 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
1
2
3
3 Lesson 20: Project
Code recap (JavaScript)
Let’s explore some of the code used in the previous lessons.
1. cpf.get(“light sensor”);
The cpf.get(“light sensor”); statement returns the value of the light sensor .
(Returns a numeric value based on the brightness level of the environment) and
stores it in a
variable called value. ui.set(“light sensor”, value); reads the value taken from the
light sensor and displays it in the program control Interface (UI).
2. cpf.set(“rgb led”, 0, 0, 0);
The cpf.set(“rgb led”, r, g, b); statement sets the colour of the attached RGB LED.
3. 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 from lesson 1, if the light sensor value is less than (<) 500, the RGB
LED light will light up (based on the values taken from the UI); or else (else), if the
light sensor value is greater than (>) 500, the RGB LED light will
automatically turn off: cpf.set(“rgb led”, 0, 0, 0);
4. Math.random()
Through Math.random(), a random number between 0 and 0.999999 is generated. If we want to generate a whole
number in a range such as 1—255 we first need to multiply the result of the random function by 255 and then
round the result to produce a whole number e.g.,
5. cpf.sleep(1000);
The cpf.sleep(1000); statement is used to pause the code (time set in milliseconds). In the example above, the
program is paused for 1000 milliseconds (1 second).
6. cpf.repeat();
Finally, the cpf.repeat(); statement, usually found 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.
7. ui.set(“content”, text);
The ui.set(“content”, text); statement, is used to display a message directly on the user interface UI.
2
4 Lesson 20: Project
Extension
Students could create an advertisement or pitch for their project. Students to include in their advertisement/pitch: Price,
target audience, unique selling point (USP), description, purpose etc.
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.
Students to research ideas for their project.
Links
Arduino project ideas: http://www.oddwires.com/arduino-project-ideas/
Disclaimer: Use these sites at your own risk. Acer is not responsible for the content of external Internet sites. We recom-
mend that you check the suitability of any recommended websites links before giving them to students.
4
5
6
7
Top Related