You are on page 1of 28

INTRODUCTION TO COMPUTER SCIENCE

UNIT 2: ALGORITHMS
Educator guide

makecode.microbit.org
CONTENTS
Overview .......................................................................................................................................................................................................................... 2
Unit summary ............................................................................................................................................................................................................. 2
Lessons ......................................................................................................................................................................................................................... 2
Learning goals............................................................................................................................................................................................................ 2
CSTA K-12 computer science standards ........................................................................................................................................................... 2
Required educator preparation ................................................................................................................................................................................ 3
Preparing to lead the unit ...................................................................................................................................................................................... 3
Required skills ............................................................................................................................................................................................................ 3
Recommended resources....................................................................................................................................................................................... 3
Lesson A: How computers function......................................................................................................................................................................... 4
Lesson plan ................................................................................................................................................................................................................. 4
Outline .......................................................................................................................................................................................................................... 4
Before the lesson ...................................................................................................................................................................................................... 4
Lesson details ............................................................................................................................................................................................................. 5
After the lesson .......................................................................................................................................................................................................11
Lesson A assessments ...........................................................................................................................................................................................11
Lesson B: Code with event handlers......................................................................................................................................................................12
Lesson plan ...............................................................................................................................................................................................................12
Outline ........................................................................................................................................................................................................................12
Before the lesson ....................................................................................................................................................................................................12
Lesson details ...........................................................................................................................................................................................................12
After the lesson .......................................................................................................................................................................................................20
Lesson B assessments............................................................................................................................................................................................21
Lesson C: Fidget cube ................................................................................................................................................................................................23
Lesson plan ...............................................................................................................................................................................................................23
Outline ........................................................................................................................................................................................................................23
Before the lesson ....................................................................................................................................................................................................23
Lesson details ...........................................................................................................................................................................................................24
After the lesson .......................................................................................................................................................................................................27
Lesson C assessments ...........................................................................................................................................................................................27

Introduction to Computer Science 2: Algorithms | 1


OVERVIEW
Unit summary
This unit introduces students to the four main components that make up a computer and the concept of input and output
as it relates to programming the micro:bit. Students will go through two unplugged activities relating to algorithms and
functions that creates a knowledge base for their coding activity and the final project. The coding activity starts with an
explanation of pseudocode that leads to working with events and event handlers to program their micro:bit to make faces.
The project incorporates all the new learning from this unit as students create their own fidget cube that responds to
different inputs.

Lessons
Each of the following lessons are intended to be broken into as many class sessions as needed to complete the activities.
Lesson A: How computers function (approximately 45-60 minutes)
Lesson B: Code with event handlers (approximately 60-75 minutes)
Lesson C: Fidget cube (approximately 60-120 minutes)

Learning goals
During this unit, students will:
▪ Understand the four components that make up a computer and their functions.
▪ Understand that the micro:bit takes input, and after processing the input, produces output.
▪ Learn the variety of different types of information the micro:bit takes in as input.
▪ Apply this knowledge by creating a micro:bit program that takes input and produces an output.

CSTA K-12 computer science standards


Targeted standards for this unit:
1B-CS-01 Describe how internal and external parts of computing devices function to form a system.
1B-CS-02 Model how computer hardware and so􀁸ware work together as a system to accomplish tasks.
1B-AP-10 Create programs that include sequences, events, loops, and conditionals.
1B-AP-17 Describe choices made during program development using code comments, presentations, and demonstrations.
2-AP-10 Use flowcharts and/or pseudocode to address complex problems as algorithms

Introduction to Computer Science 2: Algorithms | 2


REQUIRED EDUCATOR PREPARATION
Preparing to lead the unit
The following tasks are relevant to all lessons in the unit. For lesson-specific preparation tasks and any additional
materials, see the Before the lesson section of each lesson.
 Watch the correlating unit quick-start video for a brief, high-level introduction to the activities and project.
 Review all materials thoroughly and become confident with content.
 Practice all activities, and check your programming against the solution link provided with the coding activities.

Required skills
To lead the activities in this unit successfully, you need to be able to:
 Explain the features of the micro:bit.
 Use the following features and blocks in MakeCode:
▪ Start and name a new project.
▪ Download a project to the micro:bit.
▪ Tool tip functions, like right-clicking a block for Help, deleting blocks, adding comments, etc.
▪ ‘on start’, ‘show leds’, and ‘clear screen’ blocks from the Basic Toolbox.
▪ ‘on button pressed’ block from the Input Toolbox.

Recommended resources
If you would like additional support to master the concepts and skills covered in this unit, review the following resources.
▪ Learn more about basic micro:bit functions and actions at makecode.microbit.org/reference/basic.
▪ Learn more about micro:bit inputs at makecode.microbit.org/reference/input.
▪ Learn more about on start blocks at makecode.microbit.org/blocks/on-start.
▪ Review micro:bit safety advice at microbit.org/guide/safety-advice/.
▪ Search the micro:bit support knowledge base at support.microbit.org/support/home.

Introduction to Computer Science 2: Algorithms | 3


LESSON A: HOW COMPUTERS FUNCTION
Lesson plan
1. Introduce the four main components that make up any computer.
2. Lead the two unplugged activities about functions and conditionals.

Outline
Section 1: Understanding components of a computer

Overview Introduce the learning goals and introduce components of a computer

Section 2: Understanding functions and conditionals

Unplugged activity 1 What’s your function

Unplugged activity 2 Crazy conditionals

Knowledge check Check for understanding

Section 3: Wrap-up

Review Review the learning goals, what students accomplished, and preview the next lesson

Exit ticket Distribute and collect the exit ticket to assess learning

Before the lesson


 Review the overview for unplugged activity 1, and:
▪ Determine the difficulty level of the possible functions so you’re ready to share with the students ahead of playing.
Alternately, you could provide function cards that are handed out at random to be used by the players, rather
than the players creating their own.
▪ Determine if you’ll have students record their work in the provided space in the student workbooks or provide
index cards for the functions.
▪ Decide how you’ll pair students or whether you’ll let students self-select.
 Review the unplugged activity 2, and:
▪ Determine if you want to revise the activity and/or conditional statements.
▪ Determine if one of the extensions/variations is relevant.
▪ Print out the conditional statements (provided in the table) and cut them into strips with one conditional per strip.
 Although the student workbooks have space for note taking, consider having extra paper (or index cards) available, in
case any students need more space.
 Print one exit ticket per student (printable versions are found in the assessment guide).

Introduction to Computer Science 2: Algorithms | 4


Lesson details
Section 1: Understanding components of a computer
Slides 1-5

Educator notes
1. Write the “Do now” questions on the board for students to think about as they arrive:
▪ What is a computer? Answer: Responses will vary
2. Introduce the lesson and learning goals.
3. Discuss their responses to the “Do now.”

Overview: Components of a computer


What is a micro:bit? The micro:bit was created in 2015 in the UK by the BBC and partners including Microsoft to teach
computer science to students. The BBC gave away a micro:bit to every Year 7 student in the UK. You can think of a
micro:bit as a mini computer.

Introduction to Computer Science 2: Algorithms | 5


What is a computer?
There are four main components that make up any computer:

1. The Processor – this is usually a small chip inside the computer, and it’s how the computer processes and transforms
information. Has anyone heard of the term “CPU”? CPU stands for Central Processing Unit. You can think of the
processor as the Brains of the computer - the faster the processor, the more quickly the computer can think.
2. The Memory – this is how the computer remembers things. There are two types of memory:
▪ RAM (random access memory) - you can think of this as the computer’s short-term memory, things that are
stored here will disappear when the computer is turned off. Can you think of examples of things that are stored in
our short-term memory? Things that you forget after you go to sleep?
▪ Storage (also referred to as the computer “hard drive”) - this is the computer’s long-term memory, where it can
store information even when power is turned off. Can you think of examples of things that are stored in our long-
term memory? Things we never forget?
3. Inputs – this is how a computer takes in information from the world. In humans, our input comes in through our
senses, such as our ears and eyes. What are some computer Inputs? Keyboard, mouse, touchscreen, camera,
microphone, game controller, scanner, etc.
4. Outputs – this is how a computer displays or communicates information. As humans, we communicate information by
using our mouths when we talk. What are some examples of communication that don’t involve talking? Blushing, sign
language. What are some examples of computer outputs? Monitor/screen, headphones/speakers, printer, etc.
Now, let’s look at our micro:bit (Reference the micro:bit features as needed at microbit.org/guide/features/):

Note: Though not pictured, the Light Sensor is located on the LED lights.
Introduction to Computer Science 2: Algorithms | 6
Ask students:
▪ Can you find the Processor? Answer: On the back of the micro:bit, just below the Bluetooth and radio antenna.
▪ How much memory does the micro:bit have? Answer: 16K, which is smaller than many files on your computer!
▪ Can you locate the following Inputs? Answer: Buttons (on board), Pins (at base), Accelerometer / Compass.
▪ Where are the Outputs? Answer: LED lights and Pins
All computers need electricity to power them. There are three ways to power your micro:bit:
▪ Connecting the micro:bit to a computer through the USB port at the top
▪ Connecting a battery pack to the battery connector
▪ Through the 3V Pin at the bottom (not the recommended way to power your micro:bit)
On the top left corner, you may notice that your micro:bit has a Bluetooth antenna. This means your micro:bit can
communicate and send information to other micro:bits. We will learn more about this feature in Unit 10: Radio
communication.

Section 2: Understanding functions and conditionals


Slides 6-8

Educator notes
1. Follow the instructions to lead the two unplugged activities.
2. After both activities, use the knowledge check questions to confirm understanding.

What is an “unplugged” activity?


An unplugged activity is an activity that takes place away from the computer - in other words, “unplugged” from
technology. This introduces new concepts in a fun way that gets students up and moving, often reacting and interacting
with other students face-to-face while playing a game or completing a challenge. Unplugged activities allow students to
practice concepts away from devices so that when they move to coding activities, they have already walked through and
thought about the concepts on their own.

Materials
▪ Index cards (optional for the first activity)
▪ Strips of paper, each with one conditional statement on it (prepared in advance for the second activity)

Knowledge check questions


1. What are the four main components that make up any computer? Answer: The processor, the memory, the inputs
and the outputs
2. How many programable buttons are on the micro:bit? Answer: Two

Introduction to Computer Science 2: Algorithms | 7


Unplugged activity 1: What’s your function?

Objective
To guess the mathematical function based on how an input is processed.

Overview
For this activity, the students will work in pairs, Player A and Player B. The pairs will take turns being the function machine
for their partner who will be providing input to be processed. The goal is for Player A to figure out what function (or bit of
processing) Player B is using in the fewest number of rounds of input/output possible.
Here are the roles:
Player B
▪ Privately determines a mathematical function to apply to a numeric input
▪ Processes the input from Player A using the function
▪ Provides the output
Player A
▪ Provides a number for the input to Player B
▪ Guesses the function based on the output received from Player B
Examples of easier functions
▪ Add 8
▪ Subtract 6
▪ Multiply by 3
▪ Divide by 2
Examples of more difficult functions
▪ Multiply by 2 and then subtract 1
▪ Square the input
▪ Return 20% of the input
Options for students to record their work
▪ The student workbooks have a table to record inputs and outputs, or
▪ Provide index cards so Player A can write each input on one side of an index card, hand the card to Player B, who
then writes the corresponding output on the other side of the card.

Process
Share the examples of the difficulty level of functions students should use and direct students how you would like them to
record their work.
1. Player B decides on a mathematical function (or bit of processing) that will be done on whatever input she receives
from Player A. Then writes it down and sets it aside, out of sight of Player A.
2. Player A then gives Player B a number to process.
3. Player B processes the number and returns an output to Player A.
4. Player A can then state what function (or bit of processing) she thinks Player B is using on the input to produce the
given output. One try per round of input/output.
▪ If Player A states the correct function, Player B confirms that it is correct by showing the previously hidden
function and the players switch roles and start the game over.
▪ If Player A does not guess correctly, Player A provides another input that Player B processes and provides an
output for.
5. After each student has had at least one chance to be the function machine, play more rounds as time permits.
Introduction to Computer Science 2: Algorithms | 8
Unplugged activity 2: Crazy conditionals

Objective
This is a fun, interactive exercise to introduce conditionals and event handlers as computer processing.
Read through the entire activity and adjust as needed for your students and classroom.

Process
1. Hand out the conditional strips to the number of students as noted in the table below, and following these guidelines:
▪ Some of the same conditionals can be given to multiple students, while other conditionals are to be given to just
one student.
▪ Besides the ‘BEGIN’ and ‘STOP’ conditional, give at least two other conditionals to each student. A lesson from this
is that it is challenging for a student to keep track of a lot of different conditionals, though not so for a computer!
▪ Except for the first ‘BEGIN’ conditional, hand out the conditionals PRINT SIDE DOWN.
Note: Technically these conditionals are all event handlers because the students are simply waiting for a specific event
to trigger them into action.
2. Unless instructed otherwise, students do not speak or make noise during this activity.
3. Start the activity by writing BEGIN on the whiteboard.
4. As the activity progresses, trigger the six conditionals multiple times, e.g., say “popcorn,” write on the whiteboard with
a green marker, and/or snap your fingers multiple times, etc.
5. When you want to wrap up the activity, trigger the final seven conditionals by picking up a book, then the remaining
triggers, e.g., open/close the classroom door, turn the lights on/off, sharpen a pencil.

Two conditionals for all students:


▪ These two conditionals will be triggered only once.
▪ These conditionals start and stop this activity.
▪ Give the first BEGIN conditional to the students PRINT SIDE UP.

IF you see the word BEGIN on the whiteboard,


THEN flip over the conditionals in front of you and follow the directions.
IF you see the word STOP on the whiteboard,
THEN sit back, cross your arms, and look at your instructor and smile!

Six conditionals for multiple students:


▪ These six conditionals may be triggered more than once.
▪ Walk around the classroom during the activity to trigger some of these conditionals.

IF the instructor says the word “popcorn,”


THEN stand up and say “Pop!” once and sit back down.
IF any student stands up for any reason,
THEN clap three times.
IF anyone writes on the whiteboard with a GREEN marker,
THEN get up and touch something GREEN in the room and sit back down.
IF anyone walks past you while you are seated,
THEN snap your fingers three times.
Introduction to Computer Science 2: Algorithms | 9
IF someone snaps their fingers AND you have the letter “e” in your first name,
THEN select a book from the bookcase and sit back down.
IF anyone writes anything on the whiteboard,
THEN get up and turn around in place one full turn and sit back down.

Seven conditionals for one student: These will be triggered only once and set in motion the spelling of STOP on the
whiteboard.

IF the educator picks up a book,


THEN get up and write the letter S on the whiteboard and sit back down.
IF someone writes the letter S on the whiteboard,
THEN go open and close the classroom door and sit back down.
IF someone opens and closes the classroom door,
THEN get up and write the letter T (after the letter S) on the whiteboard.
IF someone writes the letter T on the whiteboard,
THEN get up and turn the lights on and off and sit back down.
IF someone turns the light on and off,
THEN get up and write the letter O (after the letter T) on the whiteboard.
IF someone writes the letter O on the whiteboard,
THEN get up and sharpen a pencil.
IF someone sharpens a pencil,
THEN get up and write the letter P (after the letter O) on the whiteboard.

Extensions/variations
▪ Add AND, OR, AND/OR statements to the conditionals.
▪ Create nested IF’s.
▪ Let students create the IF’s.
▪ Relate this activity to a system and have the students create the conditionals that would end in a product of some
kind or the completion of some task.

Knowledge check: Assess understanding


Discuss the knowledge check questions and answers with students.

Section 3: Wrap-up
Slides 9-10

Introduction to Computer Science 2: Algorithms | 10


Educator notes
1. Review learning goals with students, what they accomplished, and preview the next lesson.
2. Distribute and collect the exit ticket.

After the lesson


Assessment
 Review the exit ticket responses.

Reflection
 Consider if there were any concepts of the lesson or exit ticket students struggled with that you might want to
reinforce or reteach at the beginning of the next lesson.
 Consider what aspects of the lesson students found engaging and how you might emphasize those in the next lesson.
 Follow up on any questions that arose during the lesson that require additional research on your part.

Lesson A assessments
“Do now”
Format: Written on the board at the start of the lesson.
▪ What is a computer? Answer: Responses will vary

Knowledge check questions and answers


Format: Q&A discussions during the lesson.

Questions (slide 8) Answers

What are the four main components that make up any The processor, the memory, the inputs and the
computer? outputs

How many programable buttons are on the micro:bit? Two

Exit ticket
Format: Printed half-page handout for students to complete and turn in as they leave class. (Printer-friendly versions are
found in the assessment guide.)

Questions Answers

Name a real-life event from today’s class that caused an Responses will vary
action.

Introduction to Computer Science 2: Algorithms | 11


LESSON B: CODE WITH EVENT HANDLERS
Lesson plan
1. Lead the Happy face, sad face coding activity.
2. Assess learning with the unit quiz.

Outline
Section 1: Introduce the lesson

Overview Introduce the learning goals

Section 2: Programable smiles

Coding activity Happy face, sad face

Knowledge check Unit quiz

Section 3: Wrap-up

Review Review learning goals, what the students accomplished, and preview next lesson

Before the lesson


 Ensure you have the needed hardware for each student (or pair):
▪ Computer, laptop, or tablet
▪ Micro:bit
▪ Micro-USB cable
▪ Battery pack (with two AAA batteries)
 Print one quiz per student (see the assessment guide for a printable format).

Lesson details
Section 1: Introduce the lesson
Slides 11-12

Introduction to Computer Science 2: Algorithms | 12


Educator notes
1. Write the “Do now” on the board for students to think about as they arrive:
▪ Write down two examples of computer input and two examples of computer output. Answer: Responses will
vary
2. Introduce the lesson and learning goals.
3. Discuss their responses to the “Do now.”

Section 2: Programable smiles


Slides 13-16

Educator notes
1. Use your established equipment safety procedures for distributing and using the hardware, and ensure students are
properly set up to begin coding in MakeCode and micro:bit.
2. Follow the instructions to lead the birdhouse activity. Do the activity on your device connected to the projector or
presentation screen, and have students follow along as you complete each step. If you don’t have a projector or
screen, move throughout the room between steps to check for understanding and help facilitate the activity.
3. Pause after each step to check for understanding and take questions as needed.
4. After the activity, distribute the quiz (see the assessment guide for a printable format).
5. If you have time during class, consider reviewing the quiz answers as a group activity.

What is a “birdhouse” activity?


Each unit contains a micro:bit activity, which we informally refer to as a “birdhouse” activity, after the innumerable
wooden birdhouses so many of us made in wood shop as a way to master basic skills. The activity is an example that
walks students step-by-step through building a project that demonstrates that unit’s topic. By the time students finish
the activity, they will have written code that they can use in a different project of their own design.

Tips
Some students will finish the activity more quickly than others. Those students can then be a helpful resource for their
classmates, or they can challenge themselves by modifying, or “modding” the activity to do something different. We
have provided examples and suggestions at the end of many of these activities, and feel free to suggest your own (or
encourage your students to come up with their own ideas!)

Introduction to Computer Science 2: Algorithms | 13


Coding activity: Happy face, sad face
The micro:bit itself is considered hardware. It is a physical piece of technology. In order to make use of hardware, we need
to write software (otherwise known as “code” or computer programs). The software “tells” the hardware what to do, and in
what order to do it using algorithms. Algorithms are sets of computer instructions.
In this activity, we will discover how to use the micro:bit buttons as input devices, and write code that will make something
happen on the screen as output. We will also learn about pseudocode, the MakeCode tool, event handlers, and
commenting code.

Pseudocode
What do you want your program to do? The first step in writing a computer program is to create a plan for what you want
your program to do. Write out a detailed step-by-step plan for your program. Your plan should include what type of
information your program will receive, how this input will be processed, what output your program will create and how the
output will be recorded or presented. Your writing does not need to be written in complete sentences, nor include actual
code. This kind of detailed writing is known as pseudocode. Pseudocode is like a detailed outline or rough draft of your
program. Pseudocode is a mix of natural language and code.
For the program we will write, the pseudocode might look like this:
▪ Start with a blank screen
▪ Whenever the user presses button A, display a happy face
▪ Whenever the user presses button B, display a sad face

Microsoft MakeCode
Now that you have a plan for your program, in the form of pseudocode, let’s start creating the real program in Microsoft
MakeCode. Remember, the MakeCode tool is called an IDE (Integrated Development Environment) and is a software
application that contains everything a programmer needs to create, compile, run, test, and even debug a program.
In Microsoft MakeCode, start a new project.

Event handlers
When you start a new project, there will be two blue blocks, ‘on start’ and ‘forever’ already in the coding Workspace. These
two blocks are event handlers.
In programming, an event is an action done by the user, such as pressing a key or clicking a mouse button. An event
handler is a routine that responds to an event. A programmer can write code telling the computer what to do when an
event occurs.
Tool tips
Experiment with the following options.
1. Block descriptions - Hover over any block until a hand icon appears and a small text box will pop up telling you what
that block does. You can try this now with the ‘on start’ and ‘forever’ blocks.

Introduction to Computer Science 2: Algorithms | 14


Hovering over the code in JavaScript has the same effect.

2. Help - You can also right-click on any block and select Help to open the reference documentation.

3. Deleting blocks - Click on the ‘forever’ block and drag it left to the Toolbox area. You should see a garbage can icon
appear. Let go of the block and it should disappear. You can drag any block back to the Toolbox area to delete it from
the coding Workspace. You can also remove a block from the coding Workspace by:
▪ Hovering over the block, right-clicking, and selecting Delete Block, or
▪ Selecting the block and then pressing the “delete” key on your keyboard (or command-X on a mac).

Clear screen
Looking at our pseudocode, we want to make sure to start a program with a clear screen. We can do this by going to the
Basic menu - more and choosing a ‘clear screen’ block.

Introduction to Computer Science 2: Algorithms | 15


Drag the ‘clear screen’ block to the coding Workspace. Notice that the block is ‘grayed’ out. If you hover over the ‘grayed
out’ block, a pop-up text box will appear letting you know that since this block is not attached to an event handler block, it
will not run.

Go ahead and drag the ‘clear screen’ block into the ‘on start’ block. Now the block is no longer grayed out, indicating that
it will run when the event occurs, i.e., the program starts.

Save early, save often!


We now have a working program running on the micro:bit simulator! As you write your program, MakeCode will
automatically compile and run your code on the simulator. The program doesn’t do much at this point, but before we
make it more interesting, we should name our program and save it.
On the bottom left of the application window, to the right of the Download button, is a text box in which you can name
your program. After naming your program, press the save button to save it.

Important: Whenever you write a significant piece of code or just every few minutes, you should save your code. Giving
your code a meaningful name will help you find it faster from a list of programs and will let others know what your
program does.

Introduction to Computer Science 2: Algorithms | 16


More event handlers
Now to make our program a bit more interesting by adding two more event handlers.
From the Input menu, drag two ‘on button A pressed’ blocks to the coding Workspace. Notice that the second block is
grayed out. This is because, right now, they are the same block, both “listening” for the same event ‘on button A pressed’.

Leave the first block alone for now, and using the drop-down menu within the second block, change the A to B. Now this
block will no longer be grayed out, as it is now listening for a different event, ‘on button B pressed’.

Show LEDs
Now we can use our LED lights to display different images depending on what button the user presses.
From the Basic Toolbox, drag two ‘show leds’ blocks to the coding Workspace. Place one ‘show leds’ block into the ‘on
button A pressed’ event handler and the second ‘show leds’ block into the ‘on button B pressed’ event handler.

Introduction to Computer Science 2: Algorithms | 17


Click on the individual little boxes in the ‘show leds’ block that is in the ‘on button A pressed’ event handler to create the
image of a happy face. Click on the individual little boxes in the ‘show leds’ block that is in the ‘on button B pressed’ event
handler to create the image of a sad face.

Test your program!


In the Simulator, press button A and then button B to see the output produced by your code.
Feel free to play around with turning LEDs on or off in the ‘show leds’ blocks until you get the images you want.
Remember to save your code.

Commenting on your code


It is good practice to add comments to your code. Comments can be useful in a number of ways. Comments can help you
remember what a certain block of code does and/or why you chose to program something the way you did. Comments
also help others reading your code to understand these same things.
To comment on a block of code:
▪ Right-click on the icon that appears before the words on a block.
▪ A menu will pop up. Select ‘Add Comment’.

Introduction to Computer Science 2: Algorithms | 18


▪ This will cause a question mark icon to appear to the left of the previous icon.
▪ Click on the question mark and a small yellow box will appear into which you can write your comment.

▪ Click on the question mark icon again to close the comment box when you are done.
▪ Click on the question mark icon whenever you want to see your comment again or to edit it.
In JavaScript, you can add a comment by using two forward slashes, then typing your comment. The two forward slashes
tell JavaScript that the following text (on that same line) is a comment.

// Display a happy face when button A is pressed.

Cleaning up!
Clean up your coding Workspace before you do a final save. What does this mean?
▪ It means that only the code and blocks that you are using in your program are still in the workspace.
Introduction to Computer Science 2: Algorithms | 19
▪ Remove (delete) any other blocks that you may have dragged into the coding workspace as you were
experimenting and building your program.

Save and download


Now that your code is running just fine in the Simulator, is commented, and your coding Workspace is “clean,” save your
program, download it to your micro:bit, play and enjoy!
Complete program

Solution link: makecode.microbit.org/_WPicbA7gR7xc

Activity: Unit Quiz


Distribute the quiz (printable versions are found in the assessment guide). If you have time during class, consider
reviewing the quiz answers as a group activity.

Section 3: Wrap-up
Slides 17-18

Educator notes
1. Review learning goals with students, what they accomplished, and preview the next lesson.
2. Use your established equipment safety procedures for collecting and storing the hardware.

After the lesson


Assessment
 Review and grade the quiz (unless you reviewed with your students in class).

Introduction to Computer Science 2: Algorithms | 20


Reflection
 Consider if there were any concepts of the lesson or quiz students struggled with that you might want to reinforce or
reteach at the beginning of the next lesson.
 Consider what aspects of the lesson students found engaging and how you might emphasize those in the next lesson.
 Follow up on any questions that arose during the lesson that require additional research on your part.

Lesson B assessments
“Do now”
Format: Written on the board at the start of the lesson.
▪ Write down two examples of computer input and two examples of computer output. Answer: Responses will vary

Quiz
Format: Printed full-page handout for students to complete during class. (Please see the assessment guide for printer-
friendly versions to distribute to students.)

Questions Answers

1. What is a computer processor? d. A small chip inside the computer that the
a. Where the computer stores its memory computer uses to process and transform
b. The face of the micro:bit information
c. The area of a MakeCode project that shows how a
program looks when run on the micro:bit
d. A small chip inside the computer that the computer uses
to process and transform information

2. What is the difference between RAM and hard drive memory? a. RAM is the computer’s short-term memory
a. RAM is the computer’s short-term memory and the hard and the hard drive is where the computer
drive is where the computer stores its long-term memory stores its long-term memory
b. The hard drive is where the computer stores its short-
term memory and RAM is the computer long-term
memory
c. RAM is used for programming and the hard drive
memory is for storage
d. Hard drive memory is for storing files and RAM is used
for processing inputs

3. The term input describes: c. How a computer takes in information from


a. A type of RAM memory the world
b. A computer speaker
c. How a computer takes in information from the world
d. How a computer processes information

4. The term output describes: a. How a computer displays or communicates


a. How a computer displays or communicates information information
b. The way a computer stores memory
c. Where cords, like a USB cable, connect to a computer
d. A type of RAM memory

Introduction to Computer Science 2: Algorithms | 21


Questions Answers

b. Sets of instructions to a computer


5. What’s an algorithm?
a. The word used to describe all computer codes
b. Sets of instructions to a computer
c. A type of hardware used with micro:bit
d. The area of a MakeCode project that shows how a
program looks when run on the micro:bit

6. What’s a function machine? a. One that takes an input, processes the


a. One that takes an input, processes the input, and then input, and then delivers an output
delivers an output
b. One that can understand many different coding
languages
c. A computer designed for a single task
d. A peripheral machine that connects to a computer

7. Is a micro:bit an example of hardware or software? Hardware

8. What is pseudocode? b. A detailed step-by-step plan for your


a. The coding blocks in MakeCode program
b. A detailed step-by-step plan for your program
c. A coding language
d. A computer program

9. What is an event in programming? An action done by the user, such as pressing a


key or clicking a mouse button

10. What is an event handler? A routine that responds to an event

Introduction to Computer Science 2: Algorithms | 22


LESSON C: FIDGET CUBE
Lesson plan
1. Introduce and facilitate the coding project.

Outline
Section 1: Introduce the lesson

Overview Introduce the learning goals

Section 2: Make a fidget cube

Coding project Fidget cube

Section 3: Wrap-up

Exit ticket Students complete a Reflection Diary entry for their project

Review Review the learning goals, what students accomplished, and preview next unit

Before the lesson


 If you will be reviewing the lesson B quiz, prepare to address any themes the students are struggling with.
 Email the Reflection Diary questions for the project to students or post it in a shared drive, so students can send their
responses to you electronically.
 Ensure you have the needed hardware for each student (or pair):
▪ Computer, laptop, or tablet
▪ micro:bit
▪ Micro-USB cable
▪ Battery pack (with two AAA batteries)
 Although the student workbooks have space for note taking and drawing, consider having extra paper available, in
case any students need more designing space.
 Ensure the arts and crafts supplies are restocked, e.g.:
▪ Pizza boxes/scrap cardboard
▪ Colored construction paper
▪ Foil and copper tape
▪ Scissors
▪ Pipe cleaners
▪ Stickers/adhesives
▪ Feathers, beads, etc.
▪ String
▪ Colored markers/pencils
▪ Glue
▪ Tape

Introduction to Computer Science 2: Algorithms | 23


Lesson details
Section 1: Introduce the lesson
Slides 19-20

Educator notes
1. Write the “Do now” on the board for students to think about as they arrive:
▪ Do you ever fidget? If so, what kinds of things do you fidget with regularly? Answer: Responses will vary
2. Introduce the learning goals and discuss responses to the “Do Now.”
3. Review any themes that students are struggling with from the quiz results, unless you covered this at the end of the
last lesson.

Section 2: Make a fidget cube


Slides 21-22

Educator notes
1. Use your established equipment safety procedures for distributing and using the hardware, and ensure students are
properly set up to begin coding in MakeCode and micro:bit.
2. Follow the instructions to explain the expectations for their project, provide ideas, examples, and the scoring rubric,
which are also in the student workbook.
3. Encourage students who finish early or need an extra challenge to try one or more of the mod ideas.
4. After the activity, consider having students share their projects in pairs, small groups or the rest of the class as time
allows.
5. Be sure to allow enough time for students to complete their Reflection Diary entry in the next section.

Objective of projects
Open-ended projects are opportunities to apply the concepts and skills students have developed in an original and
creative way. Students will work on their projects in a “collaboratively independent” way, which means each student is
responsible for turning in his or her own project, but are encouraged to work together and help each other while doing
so. Some form of reflection is an important part of documenting the learning that has taken place.

Introduction to Computer Science 2: Algorithms | 24


Activity: Fidget cube
A fidget cube is a little cube with something different that you can manipulate on each
surface. There are buttons, switches, and dials, and people who like to “fidget” find it
relaxing to push, pull, press, and play with it. In this project, students are challenged to
turn the micro:bit into their very own “fidget cube”.
Show students the funny fidget cube video (5:09) in the presentation deck.
This project is to make a fidget cube out of the micro:bit and create a unique output for
each of the following inputs:
▪ on button A pressed
▪ on button B pressed
▪ on button A+B pressed
▪ on shake
See if you can combine a maker element similar to what you created in Unit 1 by providing a holder for the micro:bit that
holds it securely when you press one of the buttons.

Discussion questions
Use the following questions to help get students started:
▪ Do any of your students fidget?
▪ What kinds of things do they fidget with? Spinning pens, fidget spinners, rings, coins?
▪ There are many different versions of fidget cubes available now. Do any students have any?
▪ Have they seen them before?
▪ What are the types of fidget activities?
▪ If students could add or modify features of the fidget cube, what would they choose to do?
▪ What would make the ultimate fidget cube?
Remind students that a computing device has a number of inputs, and a number of outputs. The code that we write
processes input by telling the micro:bit what to do when various events occur.

Fidget cube example

Project mods
▪ Add more inputs and more outputs - use more than four different types of input.
▪ Try to use other types of output (other than LEDs) such as sound!

Introduction to Computer Science 2: Algorithms | 25


Project expectations
Follow the design thinking approach and make sure your project meets the required specifications:
▪ Uses at least four different inputs
▪ Uses at least four different outputs
▪ Uses event handlers in a way that is integral to the program
▪ The program compiles and runs as intended and uses meaningful comments
▪ Includes the written Reflection Diary entry (which we’ll talk about after you complete your project)

Project scoring rubric

Assessment elements 1 2 3 4

Inputs Fewer than two At least two At least three At least four different
different inputs are different inputs are different inputs are inputs are successfully
successfully successfully successfully implemented.
implemented. implemented. implemented.

Outputs Fewer than two At least two At least three At least four different
different outputs are different outputs are different outputs are outputs are successfully
successfully successfully successfully implemented.
implemented. implemented. implemented.

micro:bit program micro:bit program micro:bit program micro:bit program micro:bit program:
lacks all of the lacks two of the lacks one of the
▪ Uses event handlers
required elements. required elements. required elements.
in a way that is
integral to the
program
▪ Compiles and runs
as intended
▪ Uses meaningful
comments in code

Section 3: Wrap-up
Slides 23-25

Educator notes
1. Explain the expectations and scoring rubric for the Reflection Diary entry for their project, also in the student
workbook.
2. Review the learning goals, what students accomplished, and preview the next unit.
3. Use your established equipment safety procedures for collecting and storing the hardware.

Introduction to Computer Science 2: Algorithms | 26


Reflection Diary

Expectations
Write a reflection of about 150–300 words, addressing the following points:
▪ What problem did you solve, or why did you decide to create this project?
▪ What kind of input and output did you decide to use?
▪ What does your program do? Describe how your program works (what the cause and effect are).
▪ Include at least one screenshot of your program working.
▪ Publish your MakeCode program and include the URL.

Diary entry scoring rubric

Assessment elements 1 2 3 4

Diary entry Diary entry is Diary entry is Diary entry is Diary entry addresses all
missing three or missing two of the missing one of the elements.
more of the required elements. required elements.
required elements.

After the lesson


Assessment
 Review and grade the projects and diary entries. (A full page, printer-friendly version of the project scoring rubric is
available in the assessment guide.)

Reflection
 Consider if there were any concepts of the lesson, project or diary entries students struggled with that you might want
to reinforce or reteach before or at the beginning of the next unit.
 Consider what aspects of the lesson students found engaging and how you might emphasize those in the next unit.
 Follow up on any questions that arose during the lesson that require additional research on your part.

Lesson C assessments
“Do now”
Format: Written on the board at the start of the lesson:
▪ Do you ever fidget? If so, what kinds of things do you fidget with regularly? Answer: Responses will vary

Reflection Diary questions


Format: Provide to students electronically. Copy and paste from below.
Unit 2 Algorithms: Reflection Diary
Compose a diary entry addressing the following:
▪ What problem did you solve, or why did you decide to create this project?
▪ What kind of input and output did you decide to use?
▪ What does your program do? Describe how your program works (what the cause and effect are).
▪ Include at least one screenshot of your program working.
▪ Publish your MakeCode program and include the URL.
Introduction to Computer Science 2: Algorithms | 27

You might also like