11
1 Lesson 9: Morse Code Signalling What you will need CloudProfessor (CPF) LED 101 light component 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 lesson, students will connue to explore the basics of wring algorithms using the Blockly editor. Students will create a signalling device which is able to transmit messages in Morse code using the LED101 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 9 Morse Code Signalling 1 - - - -

Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

1 Lesson 9: Morse Code Signalling

What you will need

• CloudProfessor (CPF)

• LED 101 light component

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 lesson, students will continue to explore the basics of writing algorithms using the Blockly editor. Students will create

a signalling device which is able to transmit messages in Morse code using the LED101 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 9 Morse Code Signalling

1 ● -

- ● - ●

● - ●

Page 2: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

2 Lesson 9: Morse Code Signalling

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 LED 101 light set into the USB 3.0 slot on CloudProfessor.

3. When the CloudProfessor detects the LED 101 component, a notification will appear on your device; click the

notification to launch the open the CPF LED101 App, and then select CPF LED101 Blockly.

4. Press the execute button to enter the control user interface (UI). The UI can be used to control and turn the white

LED light and the three-coloured red, green, blue LED light on or off.

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

Step-by-step instructions (Blockly) 2

1

2

3

CPF LED101 app

Edit button

Execute button

Control user interface (UI) Program editing page

Page 3: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

3 Lesson 9: Morse Code Signalling

Code recap

Let’s explore some of the code used in lesson 8.

1. White LED Set:

The White LED Set block controls the White LED on the LED101

light component. The White LED can be either set to ’ON’ or ’OFF’

inside the program (1) or switched on or off by the user via a button

in the program UI (2). In this example, the White LED is controlled

by the program UI.

2. RGB LED Setting:

The RGB LED Setting block controls the RGB LED on the LED101 light component. Just like the White LED, each of

the red, green and blue lights on the RGB LED can be either set to ’ON’ or ’OFF’ inside the program (4) or switched

on or off individually by the user via buttons in the program UI (3). In this example, the RGB LED is controlled by the

program UI.

3. Delay Time(Sec.):

The Delay Time(Sec.) block is used to pause the code (time set in milliseconds). At the moment, this code doesn’t

really do anything but later on we will be using this to make the LED light flash on and off.

4. 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 4

Page 4: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

4 Lesson 9: Morse Code Signalling

Step-by-step instructions (Blockly)

Let’s modify the code to send a message in Morse code.

1. Clear the existing code so that you have a blank canvas to create your new program.

Click on the delete icon at the top of the code window (1).

Note: You can return to the original program at any time by clicking on the restore icon (2).

2. First, let’s set the ‘Title name’. Click on CPF UI. Select the ‘Title Name Panel

Set’ block and drag it onto your code canvas. Set the title to Morse Code’.

3. We are going to use the blue LED to represent a ‘DOT’. Lets write the code to

switch on the blue light.

Click on ‘CPF Devices’. Select the RGB LED Setting block and attach it to the

Title block. Set the blue LED to ‘ON’ and the red and green LEDs to ‘OFF’.

We also want the LED to flash for half a second.

Click on ’CPF Devices’. Select the ’Delay Time(sec.) block and attach it to the

RGB LED Setting block. Set the delay to 500 milliseconds (half a second).

4. Next, we need to add a pause (delay) between each DOT and DASH. We will

do this by turning all the LEDs off for half a second.

Add the following blocks to your code:

5. Your finished code should look like this:

4

1 2

Program the CloudProfessor to transmit a ‘DASH’. Use the red or green LED to represent a DASH.

Try sending a simple message such as the first letter of your name.

Page 5: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

5 Lesson 9: Morse Code Signalling

Extension: Sending an S.O.S (Blockly)

So far, using our existing code, we are only able to send one letter at a time but what if we wanted to send a

whole message? Let’s try sending an S.O.S

1. Clear the existing code so that you have a blank canvas to create your new

program.

Set the ‘Title name’ to S.O.S.

2. Here’s the Morse code for S.O.S Let’s start by coding the first S!

Click on ‘CPF Devices’. Select the RGB LED Setting block and attach it to the Title

block. Set the blue LED to ‘ON’ and the red and green LEDs to ‘OFF’.

Click on ’CPF Devices’. Select the ’Delay Time(sec.) block and attach it to the RGB

LED Setting block. Set the delay to 500 milliseconds (half a second).

3. Next, add a pause (delay) by turning all the LEDs off for half a second.

Add the following blocks to your code:

4. We need two more dots to represent an S. We could just copy and paste the code

above two more times but our code will start to become very long. There is,

however, a better way using functions!

Click on ’Functions’. Select the ’to do something’ block and drag it onto your code

canvas. Select the code for making the blue LED flash on/off and drag it inside the

’to do something’ block. Rename the block to ’DOT’.

5. Next, we need to call our new function (once for each DOT).

Click on Functions’. Select the ’Dot’ block and attach it to the Title block.

6. Repeat the process for all the dots and dashes. Your finished code should look like this:

5

Page 6: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

6 Lesson 9: Morse Code Signalling

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 LED 101 light set into the USB 3.0 slot on CloudProfessor.

3. When the CloudProfessor detects the LED 101 component, a notification will appear on your device; click the

notification to launch the open the CPF LED101 App, and then select CPF LED101.

4. Press the execute button to enter the control user interface (UI). The UI can be used to control and turn the white

LED light and the three-coloured red, green, blue LED light on or off.

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

Step-by-step instructions (JavaScript) 2

1

2

3

CPF LED101 app

Edit button

Execute button

Control user interface (UI) Program editing page

Page 7: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

7 Lesson 9: Morse Code Signalling

Code recap (JavaScript)

Let’s explore some of the code used in lesson 8.

1. ui.get(“white led”);

The ui.get(“white led”); controls the White LED on the LED101 light component. The White LED can be either set to

’ON’ or ’OFF’ inside the program or switched on or off by the user via a button in the program UI. In this example,

the White LED is controlled by the program UI (1).

2. cpf.set(“rgb led”, r, g, b);

The cpf.set(“rgb led”, r, g, b); block controls the RGB LED on the LED101 light component. Just like the White LED,

each of the red, green and blue lights on the RGB LED can be either set to ’ON’ or ’OFF’ inside the program or

switched on or off individually by the user via buttons in the program UI (2). In this example, the RGB LED is

controlled by the program UI.

3. 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).

4. Set CPF control request:

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.

3

2

1

Page 8: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

8 Lesson 9: Morse Code Signalling

Step-by-step instructions (JavaScript)

Let’s modify the code to send a message in Morse code.

1. Clear the existing code so that you have a blank canvas to create your new program. Press and hold on a selection

of code and click on ’Select all’ (1). Click on ‘Cut’ (2) to create a blank canvas (3).

Note: You can return to the original

program at any time by clicking on

the restore icon in the Save/load

menu.

2. First, let’s give our new script a name. Click on line 1 and type in the following: //CPF Morse

3. Let’s also set the title of our app. Click on line 3 at type the following: ui.set(“title”, “CPF Morse”);

4. We are going to use the blue LED to represent a ‘DOT’. Lets write the code to switch on the blue light.

Click on line 5 and type in the following:

cpf.set(“rgb led”, 0, 0, 1);

We also want the LED to flash for 500 milliseconds (half a second).

Click on line 7 and type the following:

cpf.sleep(500);

5. Next, we need to add a pause (delay) between each DOT and DASH. We will do this by turning all the LEDs off for

half a second.

Click on 9 and add the following lines of code:

cpf.set(“rgb led”, 0, 0, 1);

cpf.sleep(500);

6. Run your code.

4

Program the CloudProfessor to transmit a ‘DASH’. Use the red or green LED to represent a DASH.

Try sending a simple message such as the first letter of your name.

1

3

2

Your finished code should look like this.

Page 9: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

9 Lesson 9: Morse Code Signalling

Extension: Sending an S.O.S (JavaScript)

So far, using our existing code, we are only able to send one letter at a time but what if we wanted to send a

whole message? Let’s try sending an S.O.S

1. First, let’s give our new script a name. Click on line 1 and type in the following: //CPF Morse

2. Let’s also set the title of our app. Click on line 3 at type the following: ui.set(“title”, “CPF Morse”);

3. Here’s the Morse code for S.O.S Let’s start by coding the first S!

Click on line 6 and type in the following:

cpf.set(“rgb led”, 0, 0, 1);

cpf.sleep(500);

cpf.set(“rgb led”, 0, 0, 1);

cpf.sleep(500);

4. We need two more dots to represent an S. We could just copy and paste the code above two more times but our

code will start to become very long. There is, however, a better way using functions!

Click on line 5 and type in the following:

function dot() {

Now let’s end our function. Click on line 10 and type in the following:

}

5. Let’s repeat this process for our DASH code. Click on line 12

and type the following:

function dot() {

cpf.set(“rgb led”, 0, 0, 1);

cpf.sleep(500);

cpf.set(“rgb led”, 0, 0, 1);

cpf.sleep(500);

}

6. Next, we need to call our new function (once for each DOT). As

our first letter S is made of 3 dots, we will need to call our

function 3 times.

Click on line 19 and type in the following:

// S

dot();

dot();

dot();

7. Repeat the process for all the dots and dashes.

8. Run your code.

5

Your finished code should look like this.

Important! Make sure you leave

a space in front of lines 6 to 12.

Page 10: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

10 Lesson 9: Morse Code Signalling

Student Worksheet

Instructions:

Send a message, using the table below, for your partner to decode.

Start with something simple such as your initials.

Use the blue light for and the red light for a

(You will need to agree with your partner how long to pause between each letter)

Morse code:

Examples:

S.O.S

● ● ● / - - - / ● ● ●

HELLO

● ● ● ● ● / ● / ● - ● ● / ● - ● ● / - - -

ACER ● - / - ● - ● / ● / ● - ●

6

Page 11: Lesson - Acer for Education Magazine · ô Lesson 9: Morse Code Signalling Step-by-step instructions (JavaScript) Let’s modify the code to send a message in Morse code.. lear the

11 Lesson 9: Morse Code Signalling

Extension

Students to write a simple message in Morse code and transmit it to a partner using the CloudProfessor .

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 explore other types of ciphers such as sliding scale, substitution and scytale ciphers. Students to create their

own cipher to allow them to send secret coded messages to their friends.

Links

Morse code—Wikipedia: https://en.wikipedia.org/wiki/Morse_code

How it works—Morse code: https://www.youtube.com/watch?v=xsDk5_bktFo

How to learn Morse code: http://www.wikihow.com/Learn-Morse-Code

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.

7

8

9

10