Intro To CS With MakeCode For Microbit
Intro To CS With MakeCode For Microbit
Intro To CS With MakeCode For Microbit
When we first started teaching computer science, we discovered two important things. We
found that existing curriculum for beginners focused mostly on solving math problems or
constructing geometric shapes and that there was a certain type of student that signed up for
computer science classes and these students were almost always boys. We wondered whether a
different approach to teaching the basics of computer programming would be more engaging
and also attract a larger variety of different types of students, both boys and girls.
We decided to focus on what knowing how to program allowed you to do and create. Ultimately
all programs are created to solve a problem or serve a purpose. The problem may be local or
global, the purpose may be anything from helping doctors treat patients to pure entertainment.
By starting with interesting problems the students wanted to solve, they were much more
engaged in learning to code. They saw coding skills as an important part of building creative
solutions.
With this approach, we found that not only did we get more girls taking the course, we also got
a more diverse group of boys. Opportunities for collaboration increased, and all the students
got to see where their talents and skills meshed with others' interests and experiences, to make
a whole that was greater than the sum of its parts.
We are now at the point where a third of the students taking computer science are girls, and
more importantly, students are coming out of the course not only with an understanding of
code, but also knowing how to read through professionally written code, and take an idea from
brainstorming through prototyping to build something that matters.
Course Introduction
This is an introduction to coding and computer science by way of making and design, using the
revolutionary new micro:bit microcontroller board, and Microsoft's easy and powerful
MakeCode block-based coding environment. It is a project-based curriculum with a maker
philosophy at its core; the idea is that by making physical objects, students create a context for
learning the coding and computer science concepts.
Introduction Page 1
• Micro:bits may be purchased from these resellers: http://microbit.org/resellers (you will
need 1 micro:bit per student for this course). The "Micro:bit Go Kit" includes a battery
pack and USB cable as well.
• Other optional suggested micro:bit accessories include:
○ Alligator/Crocodile clip cables
Introduction Page 2
○ Croc clip to Headphone jack adapter (http://microbit-accessories.co.uk/)
When students complete this course they will have a good understanding of computer science
concepts that can serve as the foundation for future study. They will develop powerful design
skills that they can use in future projects of all types, whether they are designing 3D printed
prototypes or creating apps that serve a real world purpose.
This course is targeted to middle school grades 6-8 (ages 11-14 years). It is also written for
teachers who may not have a Computer Science background, or may be teaching an "Intro to
Computer Science" course for the first time.
This course takes approximately 14 weeks to complete, spending about 1 week on each of the
first 11 lessons, and 3 weeks for students to complete the final project at the end. Of course,
teachers should feel free to customize the curriculum to meet individual school or district
resources and timeframe.
Introduction Page 3
8. Booleans
9. Bits, Bytes, and Binary
10. Radio
11. Arrays
12. Independent Final Project
•
•
•
Topic Introduction
The introduction to each lesson will tell you what learning objectives are covered in the lesson,
and presents an overview of that lesson's topic. Some lessons have a specific activity that can
help introduce the topic to students in a fun way.
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 Page 4
that is creative and original. Students will be working 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, and it's a great
idea to share out the final projects and reflections, either at an event or on a blog.
There are also a series of Project Mods that students can do to extend the project they have
created. These are useful for students who already have some experience with coding or who
want an extra challenge.
Assessment
A rubric is provided for each project that can be customized according to what students are
being asked to demonstrate. For the Activities we just expect students to do them, so those are
fairly simple to check off. For the Projects, however, there is often a range of grades based on
how closely the project meets the specifications of the assignment.
Standards
Where applicable, we have mapped each of the lessons to the Computer Science Teachers
Association (CSTA) K-12 Standards, which are US nationally recognized standards for computer
science education.
Introduction Page 5
References
We have included some additional reference books and materials if you are interested in learning more about Maker Education,
Physical Computing or Design Thinking in the classroom.
• Invent To Learn
Making, Tinkering, and Engineering in the Classroom
By Sylvia Libow Martinez & Gary Stager
• Launch
Using Design Thinking to Boost Creativity and Bring Out the Maker in Every Student
by John Spencer and AJ Juliani
If you have feedback for the Microsoft MakeCode team, you can fill our their survey form here: https://aka.ms/microbitfeedback
Introduction Page 6
About The Authors
Douglas Kiang is a speaker, teacher, and workshop presenter with twenty-seven years of teaching experience in
independent schools at every grade level. He currently teaches high school computer science at Punahou
H ,H D ’ ,I ,
Harvard and is a Microsoft Innovative Educator.
You can follow him on Twitter at @dkiang.
Mary Kiang has been teaching for over twenty-five years at elementary, middle, and high school levels. She
also developed curriculum in the Education Department of the Museum of Science in Boston. She currently
teaches 6th grade Math/Science at Punahou School. Mary is a former programmer for Houghton Mifflin and
D &B ’
founder of GO Code!, an organization that supports girls and young women in exploring coding and STEM.
About Page 7
Making with Micro:bit
This Lesson introduces the Micro:bit as a piece of hardware that has a specific size and weight, and
generally must be supported and incorporated as an essential component of a tangible artifact. Focus on
incorporating the physical Micro:bit into a basic making activity.
Lesson Objectives
…
• Exercise creativity and resourcefulness by coming up with ideas for using simple household materials
’ z
• Test and iterate using different materials and sizes in order to create an optimal design to house the
micro:bit and battery pack
• Learn how to download programs and move them to the Micro:bit file to run on the Micro:bit.
• Use the design thinking process to develop an understanding for a problem or user need.
• “ ”
Introduction
The Micro:bit is a great way to teach the basics of programming and computer science. The Microsoft
MakeCode block-based coding environment is a powerful and intuitive way to make the Micro:bit react to
all sorts of input, and you can introduce fundamental concepts such as iteration, conditional statements,
and variables using MakeCode.
Students often focus primarily on the 5x5 LED screen for providing output. Although this is the most
directly accessible way to see a reaction to some kind of input, there are many more creative possibilities
“ ” ,
creations.
01.Making Page 8
’ I’
common household supplies. Because the micro:bit is so lightweight, and supports so many sensors, it can
be incorporated easily into a physical design as long as students plan ahead for its size and weight. One of
q “W ?”
I ’ , “ ”
We purposely start this course with a lesson on Making and the physical nature of the micro:bit, because it
is important to set the tone for the whole course that this is a class about making, building, crafting and
construction. It helps if you have an art room available where kids can work, or arts and crafts supplies in
your classroom that kids can use to build.
01.Making Page 9
Unplugged: Design Thinking
Objective: To introduce a process of design that starts with talking to one another. Whatever
you build with code should serve a purpose or fill a need. Sometimes what you build will make
the world more beautiful, or help somebody else. Our design process, based on a process called
design thinking, can give students a specific framework for thinking purposefully about design.
Overview: In this activity, students will interview each other about their ideal pet. They should
take notes.
’ ,
create prototypes that get you closer and closer to the best solution.
Materials:
Pairs of students, something to take notes on
Getting started:
Pair students up with each other. One is Student A, the other is Student B. The goal of this
activity is to gather information from their partner that will help them to design a Micro:bit pet
for their partner.
5 minutes: Student A interviews Student B. The goal is to find out what Student B considers to
be their ideal pet. Student A should mostly listen, and ask questions to keep Student B talking
for the entire time. Here are some questions to start with:
q “W ?”
01.Making Page 10
q “W ?”
as possible. Your partner will tell you about his or her ideal pet, but you are really finding out
’ W ,
people. So we need to start with understanding them first.
5 minutes: Student A and Student B review their notes, and circle anything that seems as if it will
be important to understanding how to create the ideal pet for their partner. Circle ideas, advice,
anything that could be helpful when they start building. Then, they should use what they have
discovered about their partner to fill in the blanks:
This definition statement should draw some conclusions about their partner's need based on the
conversation they have had with that person.
5 minutes: Student A and Student B sketch at least 5 ideas of pets that would meet their
partner's needs. Stick figures and diagrams are okay. At this point, quantity is more important
than quality. Students shouldn't limit themselves to real animals; unicorns and mashups are
totally fine!
Make sure students keep their notes and sketches! They will use them in the project for this
lesson.
Examples
01.Making Page 11
01.Making Page 12
01.Making Page 13
Activity: Installing a Program
Overview: Students will create a simple program in Microsoft MakeCode and download it to
their Micro:bit using a USB cable.
For this activity, students will each need a Micro:bit, a micro-USB cable, a computer, and a
battery pack.
microbit-Mi
croPet
Open a browser window to makecode.com, and select the micro:bit code editor
From the top left corner of the screen, select the Projects Menu, and click on Import File.
Select the file that you saved on your computer in the previous step.
01.Making Page 14
Select the file that you saved on your computer in the previous step.
basic.forever(() => {
basic.showIcon(IconNames.Happy)
basic.pause(5000)
basic.showIcon(IconNames.Sad)
basic.pause(5000)
})
MicroPet
01.Making Page 15
Tour of Microsoft MakeCode
• Simulator - on the left side of the screen, you will see a virtual micro:bit that will show what
your program will look like running on a micro:bit. This is helpful for debugging, and
instant feedback on program execution.
• Toolbox - in the middle of the screen, there are a number of different categories, each
containing a number of blocks that can be dragged into the programming workspace on
the right.
• Workspace - on the right side of the screen is the Programming Workspace where you will
create your program. Programs are constructed by snapping blocks together in this area.
The color of the blocks identifies their category. All of the blocks that make up the program
above come from the Basic Toolbox category, which is light blue.
01.Making Page 16
a USB flash drive.
Click the purple Download button in the lower left of the MakeCode screen. This will download
the file to your computer, to the location where your browser is set to save downloads.
To move the program to your micro:bit, drag the downloaded "microbit-xxxx.hex" file to the
MICROBIT drive, as if you were copying a file to a flash drive. The program will copy over, and it
will begin running on the micro:bit immediately.
The micro:bit will hold one program at a time. It is not necessary to delete files off the micro:bit
before you copy another onto the micro:bit; a new file will just replace the old one.
For the next project, your students should attach the battery pack (it takes 2 AAA batteries) to
the micro:bit using the white connector. That way they can build it into their design without
having to connect it to the computer.
01.Making Page 17
01.Making Page 18
Project: Micro:pet
Project
This project is an opportunity for students to create a micro:pet for the partner they interviewed in the
Unplugged activity. They should review their notes and try to summarize what their partner finds appealing in a
pet. Then, they should use whatever materials are available to create a prototype of a pet their partner would
like.
We often ask students to sketch a few designs on paper first, then consult with their partner to see which
aspects of those designs they find most appealing. The purpose of prototyping is to gather more feedback to
“I I , I I B…”
Your design should use whatever materials are available to support the micro:bit so that its face is showing. You
can be creative and decide how to mount the board, and how to decorate your critter.
Reflection
Have students write a reflection of about 150–300 words, addressing the following points:
• Summarize the feedback you got from your partner on your idea. How would you revise your design, if
you were to go back and create another version?
• What was it like to have someone designing a pet for you? Was it a pet you would have enjoyed? Why or
why not? What advice did you give them that might help them redesign?
• What was it like to interview your partner? What was it like to be listened to?
• What was something that was surprising to you about the process of designing the micro:pet?
• Describe a difficult point in the process of designing the micro:pet, and explain how you resolved it.
Rubric
For creative projects such as these, we normally don’t use a qualitative rubric to grade the creativity or the
match with their partner’s needs. We just check to make sure that the micro:pet meets the required
specifications:
Program properly downloaded to micro:bit
01.Making Page 19
• Program properly downloaded to micro:bit
• Micro:bit supported so the face is showing
• Micro:bit can be turned on and off without taking critter apart
• Turned in notes on interview process
• Written reflection (prompt is above)
Micro:Pet Examples
Dog
01.Making Page 20
Pink Piggy
Ladybug
01.Making Page 21
Caterpillar
Fox
01.Making Page 22
Robot
01.Making Page 23
Standards
• 2-A-2-1 Solicit and integrate peer feedback as appropriate to develop or refine a program
• 2-A-6-10 Use an iterative design process (e.g., define the problem, generate ideas, build,
test, and improve solutions) to solve problems, both independently and collaboratively.
01.Making Page 24
Algorithms
This lesson introduces a conceptual framework for thinking of a computing device as something that uses code to
process one or more inputs and send them to an output(s).
Lesson Objectives
…
• 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.
Introduction
What is a micro:bit?
The micro:bit was created in 2015 in the UK by the BBC 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.
http://microbit.org
What is a computer?
There are 4 main components that make up any computer:
02.Algorithms Page 25
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
○ Storage (also referred to as the “hard drive”) - this is the computer’s long-term memory, where it can store
information even when power is turned off
3. Inputs – this is how a computer takes in information from the world. On 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
All computers need electricity to power them. There are 3 ways to power your micro:bit:
• Through the USB port at the top
By connecting a battery pack to the battery connector
02.Algorithms Page 26
• By 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 the Radio Lesson.
02.Algorithms Page 27
Unplugged: What's Your Function & Crazy Conditionals
Materials
• Pencils
• Paper (or index cards)
‘ ’ , ,
‘ ’
A function machine takes an input, processes the input, and then delivers an output.
The inputs and their outputs are usually recorded in an input output table, where the value of x represents the
input and the value of y represents the output. See example.
02.Algorithms Page 28
input and the value of y represents the output. See example.
A common math problem is to determine what processing is happening to the input that results in the given
output. In the example above, each input is being doubled (multiplied by 2) to produce the corresponding output.
Direct the students how you would like them to record their work.
They can use pencil and paper or index cards.
On paper, they can keep track of inputs and outputs in a table (see example above).
With index cards, 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.
To begin:
• Player B decides on a mathematical function or bit of processing* that will be done on whatever input she
receives from Player A.
• Player B should write down the function or bit of processing and set it aside, out of sight of Player A.
• Player A then gives Player B a number to process.
• Player B processes the number and returns an output to Player A.
• 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.
• 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.
• After each student has had at least one chance to be the function machine, play more rounds as time permits.
Notes:
• The difficulty level of the possible functions should be determined by the teacher and shared with the
students ahead of playing. Alternately, the teacher can provide function cards that are handed out at random
to be used by the players, rather than the players creating their own.
The player providing the input should not just guess what the function is. She should be able to explain why
02.Algorithms Page 29
• The player providing the input should not just guess what the function is. She should be able to explain why
she thinks her input resulted in the given output.
• ‘ ’
○ 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
Preparation:
• Print & cut into strips with one conditional on each strip
• Note that some of the same conditionals can be given to multiple students, while other conditionals are to be
given to just one student.
• ‘B GIN’ , RIN ID DOWN
• B ‘B GIN’ ‘ O ’ ,
this is that it is challenging for a student to keep track of a lot of different conditionals, though not so for a
computer! : )
Notes:
• Some of the same conditionals can be given to multiple students, while other conditionals are to be given to
just one student.
• Technically these conditionals are all event handlers because the students are simply waiting for a specific
event to trigger them into action.
• Unless instructed otherwise, students do not speak or make noise during this activity.
Extensions/Variations:
• Add AND, OR, AND/OR statements to the conditionals.
• IF’
• L IF’
• 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.
=================================================================
02.Algorithms Page 30
Give these 6 conditionals to multiple students.
• These 6 conditionals may be triggered more than once.
• Walk around the classroom during the activity to trigger some of these conditionals.
IF ‘ ’,
THEN ‘ !’
=================================================================
02.Algorithms Page 31
Activity: Happy Face, Sad Face
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 a browser window, open the Microsoft MakeCode for micro:bit tool
(https://makecode.microbit.org). 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.
02.Algorithms Page 32
Event handlers
W , ,‘ ’ ‘ ’
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.
One fun unplugged activity you can do with kids to reinforce the idea of an action that waits for
an event is the Crazy Conditionals activity.
Notes:
• Tooltips - Hover over any block until a hand icon appears and a small text box will pop up
Y ‘ ’ ‘ ’
blocks. Notice that it also shows you the equivalent code in JavaScript.
• Help/Documentation - You can also right-click on any block and select Help to open the
reference documentation.
02.Algorithms Page 33
reference documentation.
• 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 your coding window by selecting the block and then
pressing the "delete" key on your keyboard (or command-X on a mac).
Looking at our pseudocode, we want to make sure to start a program with a clear screen.
• D ‘ ’ W
N ‘ ’ I ‘ ’ ,
box will appear letting you know that since this block is not attached to an event handler
block, it will not run.
• G ‘ ’ ‘ ’ N
longer grayed out, indicating that it will run when the event, the program starts, occurs.
basic.clearScreen()
02.Algorithms Page 34
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.
• Leave the first block alone for now, and using the drop-down menu within the second
, ‘ ’ ‘B’ N ,
,‘ B ’
input.onButtonPressed(Button.A, () => {
})
input.onButtonPressed(Button.B, () => {
})
Show LEDs
Now we can use our LED lights to display different images depending on what button the user
presses.
• F B , ‘ ’
• ‘ ’ ‘ ’
‘ ’ ‘ B ’
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. . . . .
. . . . .
02.Algorithms Page 35
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
• ‘ ’ ‘
’
• ‘ ’ ‘ B
’
input.onButtonPressed(Button.A, () => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
})
input.onButtonPressed(Button.B, () => {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`)
})
02.Algorithms Page 36
Commenting 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.
• 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.
Notes
• When you right-click on the icon that appears before the words on a block, notice that
there are other options available to you that allow you to duplicate and delete blocks, as
well as get help. Feel free to explore and use these as you code.
02.Algorithms Page 37
well as get help. Feel free to explore and use these as you code.
• 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.
• Remove (delete) any other blocks that you may have dragged into the coding workspace
as you were experimenting and building your program.
HappySadFace
02.Algorithms Page 38
02.Algorithms Page 39
Project: Fidget Cube
A fidget cube is a little cube with something different that you can manipulate on each surface.
, , , “ ” ,
pull, press, and play with it. In this project, students are challenged to turn the micro:bit into
“ ”
Discussion questions
• 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.
Project
Make a fidget cube out of the micro:bit, 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 Lesson 1 by providing a
holder for the micro:bit that holds it securely when you press one of the buttons.
02.Algorithms Page 40
Sample Fidget Cube designs
Project Mod
• Add more inputs and more outputs - use more than 4 different types of input. Try to use
other types of output (other than LEDs) such as sound!
Assessment
4 3 2 1
Inputs At least 4 different At least 3 At least 2 Fewer than 2
inputs are different inputs different inputs different inputs are
successfully are successfully are successfully successfully
implemented implemented implemented implemented
Outputs At least 4 different At least 3 At least 2 Fewer than 2
outputs are different outputs different outputs different outputs
successfully are successfully are successfully are successfully
implemented implemented implemented implemented
Micro:bit Micro:bit program: Micro:bit program Micro:bit program Micro:bit program
program • uses event lacks 1 of the lacks 2 of the lacks all or of the
handlers in a way required elements required elements required elements
that is integral to
the program
• compiles and runs
as intended,
• includes
meaningful
comments
Collaboration Reflection piece Reflection piece Reflection piece Reflection piece
reflection includes: lacks 1 of the lacks 2 of the lacks 3 of the
• brainstorming required elements required elements required elements
ideas
02.Algorithms Page 41
ideas
• construction
• programming
• beta testing
02.Algorithms Page 42
Standards
02.Algorithms Page 43
Variables
This lesson introduces the use of variables to store data or the results of mathematical
operations. Students will practice giving variables unique and meaningful names. And we will
introduce the basic mathematical operations for adding subtracting, multiplying, and dividing
variables.
Lesson Objectives
…
• Understand what variables are and why and when to use them in a program.
• Learn how to create a variable, set the variable to an initial value, and change the value of
the variable within a micro:bit program.
• Learn how to create meaningful and understandable variable names.
• Understand that a variable holds one value at a time.
• Understand that when you update or change the value held by a variable, the new value
replaces the previous value.
• Learn how to use the basic mathematical blocks for adding, subtracting, multiplying, and
dividing variables.
• Apply the above knowledge and skills to create a unique program that uses variables as
an integral part of the program.
Introduction
Computer programs process information. Some of the information that is input, stored, and
used in a computer program has a value that is constant, meaning it does not change
throughout the course of the program. An example of a constant ‘ ’ ‘ ’
has one value that never changes. Other pieces of information have values that vary or change
during the running of a program. Programmers create variables to hold the value of
information that may change. In a game program, a variable may be created to hold the
’ , !
game.
Ask the students to think of some pieces of information in their daily life that are constants and
03.Variables Page 44
Ask the students to think of some pieces of information in their daily life that are constants and
others that are variables.
• W ’
day (constants)?
• What pieces of information have values that do change during the course of a single day
(variables)
Constants and variables can be numbers and/or text.
Examples
I …
• , , ’ , ’
• Variables: The temperature/weather, the current time, the current class, whether they are
…
Variables hold a specific type of information. The micro:bit's variables can keep track of
numbers, strings, booleans, and sprites. The first time you use a variable, its type is assigned to
match whatever it is holding. From that point forward, you can only change the value of that
variable to another value of that same type.
• A number variable could hold numerical data such as the year, the temperature, or the
degree of acceleration.
• A string variable holds a string of alphanumeric characters such as a person's name, a
password, or the day of the week.
• A boolean variable has only two values: true or false. You might have certain things that
happen only when the variable called gameOver is false, for example.
• A sprite is a special variable that represents a single dot on the screen and holds two
separate values for the row and column the dot is currently in.
03.Variables Page 45
Unplugged: Keeping Score
To experience creating and working with variables, have students pair up and play Rock Paper
Scissors.
Students will keep track of how many times each player wins as well as the number of times the
players tie.
Play: Have students play Rock Paper Scissors for about a minute. When done, ask the students
‘ ’
Play again: Tell students they will now start over and play again for another minute. When
, ‘ ’
Ask some students to share how they kept track of player scores.
, ’
, ‘ ’
made a separate place for recording ties.
03.Variables Page 46
Sample Score-keeping sheet
Ask the students what parts of the score sheet represent constants, values that do not change
’
Ask the students what parts of the score sheet represent variables, values that do change
’
03.Variables Page 47
Activity: Scorekeeper
This Micro:bit activity guides the students to create a program with three variables that will keep score for their Rock
Paper Scissors game.
Tell the students that they will be creating a program that will act as a scorekeeper for their next Rock Paper Scissors
game. They will need to create variables for the parts of scorekeeping that change over the course of a gaming
session. What are those variables?
• The number of times the first player wins
• The number of times the second player wins
• the number of times the players tie
Creating and naming variables: Lead the students to create meaningful names for their variables.
• What would be a unique and clear name for the variable that will keep track of the number of times Player A
wins?
• ‘ W’, ’, ‘ B ’, ‘ B ’, ‘ W ’
• Discuss why (or why not) different suggestions make clear what value the variable will hold. In general, variable
names should clearly describe what type of information they hold.
In MakeCode, from the Variables menu, make and name these three variables: PlayerAWins, PlayerBWins, PlayersTie
03.Variables Page 48
let PlayerAWins = 0
let PlayerBWins = 0
let PlayersTie = 0
We already initialized these variables and now need to code to update the values at each round of the game.
• Each time the scorekeeper presses button A to record a win for Player A, we want to add 1 to the current value of
‘ W ’
• Each time the scorekeeper presses button B, to record a win for Player B, we want to add 1 to the current value
‘ BW ’
• Each time the scorekeeper presses both button A and button B at the same time to record a tie, we want to add
1 to the current value of the variable PlayersTie
F I , ‘ ’
L ‘ ’ - ‘B’ ‘ +B’
third block.
F V , ‘ ’
Place one change block into each of the Button Pressed blocks.
Choose the appropriate variable from the pull down menus in the change blocks.
03.Variables Page 49
input.onButtonPressed(Button.A, () => {
PlayerAWins += 1
})
input.onButtonPressed(Button.B, () => {
PlayerBWins += 1
})
input.onButtonPressed(Button.AB, () => {
PlayersTie += 1
})
User feedback
Whenever the scorekeeper presses button A, button B, or both buttons together, we will give the user visual feedback
acknowledging that the user pressed a button. We can do this by coding our program to display:
• ‘ ’ ,
• ‘B’ ‘B’ B,
• ‘ ’ B
W ‘ ’, ‘B’, ‘ ’ ‘ ’ ‘ ’
I , ‘ ’
03.Variables Page 50
input.onButtonPressed(Button.A, () => {
PlayerAWins += 1
basic.showLeds(`
. # # # .
. # . # .
. # # # .
. # . # .
. # . # .
`)
basic.clearScreen()
})
input.onButtonPressed(Button.B, () => {
PlayerBWins += 1
basic.showLeds(`
. # # . .
. # . # .
. # # # .
. # . # .
. # # . .
`)
basic.clearScreen()
})
input.onButtonPressed(Button.AB, () => {
PlayersTie += 1
basic.showLeds(`
. # # # .
. . # . .
. . # . .
. . # . .
. . # . .
`)
basic.clearScreen()
})
03.Variables Page 51
N ‘ ’ ‘ ’, ‘B’, ‘ ’
What do you think would happen if we did not clear the screen? Try it.
let PlayersTie = 0
let PlayerBWins = 0
let PlayerAWins = 0
input.onButtonPressed(Button.A, () => {
PlayerAWins += 1
basic.showLeds(`
. # # # .
. # . # .
. # # # .
. # . # .
. # . # .
`)
basic.clearScreen()
})
input.onButtonPressed(Button.B, () => {
PlayerBWins += 1
basic.showLeds(`
. # # . .
. # . # .
03.Variables Page 52
. # . # .
. # # # .
. # . # .
. # # . .
`)
basic.clearScreen()
})
input.onButtonPressed(Button.AB, () => {
PlayersTie += 1
basic.showLeds(`
. # # # .
. . # . .
. . # . .
. . # . .
. . # . .
`)
basic.clearScreen()
})
input.onGesture(Gesture.Shake, () => {
basic.showString("Wins:")
basic.showLeds(`
. # # # .
. # . # .
. # # # .
. # . # .
. # . # .
`)
basic.showNumber(PlayerAWins)
basic.pause(1000)
basic.showLeds(`
. # # . .
. # . # .
. # # # .
. # . # .
. # # . .
`)
basic.showNumber(PlayerBWins)
basic.pause(1000)
basic.showString("Ties:")
basic.showNumber(PlayersTie)
basic.pause(1000)
basic.clearScreen()
})
PlayerAWins = 0
PlayerBWins = 0
PlayersTie = 0
Scorekeeper
03.Variables Page 53
Try it out!
Download the Scorekeeper program to the micro:bit, and have the students play one last round of Rock Paper Scissors
using their micro:bits to act as the Scorekeeper!
’ , ‘ ’
this, we can add the values stored in the variables we created to keep track of how many times each player won and
how many times they tied.
In order to do this, we can add the code to our program under the 'on shake' event handler .
• First, display a string to show the player that the following sum represents the total number of rounds played.
• Our program will add the values stored in the variables 'PlayerAWins', 'PlayerBWins', and 'PlayersTie' and then
display the sum of this mathematical operation.
• The blocks for the mathematical operations adding, subtracting, multiplying, and dividing are listed in the Math
section of the Toolbox.
Note: Even though there are 4 blocks shown for these 4 operations, you can access any of the four operations
from any of the four blocks, and you can also access the exponent operation from these blocks.
03.Variables Page 54
• Replace the default values of zero with the names of the variables we want to add together.
Notice that because we are adding three variables together we need a second math block. First we add the
values for 'PlayerAWins' and 'PlayerBWins', then add 'PlayersTie'.
input.onGesture(Gesture.Shake, () => {
basic.showString("Total rounds played:")
basic.showNumber(PlayerAWins + PlayerBWins + PlayersTie)
• Save, download, and try the program again to make sure that it runs correctly and displays the correct numbers
for each variable.
Remember that the micro:bit is a device that processes input and displays it as output in some way. By storing values
in variables, you can perform mathematical operations on that data that provides you with useful information.
What other math operations could provide valuable information from the values stored in these variables?
Examples:
’
03.Variables Page 55
• ’
• Calculate a display the number of tied games as a percentage of all rounds played.
03.Variables Page 56
Project: Everything Counts
This is an assignment for students to come up with a Micro:bit program that counts something.
Their program should keep track of input by storing values in variables, and provide output in some visual and useful way.
Students should also perform mathematical operations on the variables to give useful output.
Input
Remind the students of all the different inputs available to them through the Micro:bit.
Project Ideas
’
In baseball during an at-bat, umpires must keep track of how many pitches have been thrown to each batter. Use Button A to record the
number of balls (up to 4) and the number of strikes (up to 3).
Extra Mod: Create a way to reset both variables to zero, create a way to see the number of balls and strikes on the screen at the same time.
Shake counter
Using the 'On Shake' block, you can detect when the micro:bit has been shaken and increment a variable accordingly. Try attaching the
micro:bit to a lacrosse stick and keep track of how many times you have successfully thrown the ball up in the air and caught it.
Extra Mod: Make the micro:bit create a sound of increasing pitch every time you successfully catch the ball.
Pedometer
See if you can count your steps while running or doing other physical activities carrying the micro:bit. Where is it best mounted?
D ’
Calculator
Create an adding machine. Use Button A to increment the first number, and Button B to increment the second number. Then, use Shake or
Buttons A + B to add the two numbers and display their sum.
Extra Mod: Find a way to select and perform other math operations.
03.Variables Page 57
Homemade Top with Micro:bit Revolution Counter
Process
In any design project, it's important to start by understanding the problem. You can begin this activity by interviewing people around you
who might have encountered the problem you are trying to solve. For example, if you are designing a wallet, ask your friends how they store
03.Variables Page 58
who might have encountered the problem you are trying to solve. For example, if you are designing a wallet, ask your friends how they store
their money, credit cards, identification, etc. What are some challenges with their current system? What do they like about it? What else do
they use their wallets for?
If you are designing something else, think about how you might find out more information about your problem through interviewing or
observing people using current solutions.
Then start brainstorming. Sketch out a variety of different ideas. Remember that it's okay if the ideas seem far-out or impractical. Some of the
best products come out of seemingly crazy ideas that can ultimately be worked into the design of something useful. What kind of holder can
you design to hold the Micro:bit securely? How will it be used in the real world, as part of a physical design?
Use the simulator to do your programming, and test out a number of different ideas. What is the easiest way to keep track of data? If you are
designing for the accelerometer, try to see what different values are generated through different actions (you can display the value the
accelerometer is currently reading using the 'Show Number' block; clear the screen afterward so you can see the reading).
basic.forever(() => {
basic.showNumber(input.acceleration(Dimension.X))
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
Reflection
Have students write a reflection of about 150–300 words, addressing the following points:
• What was the problem you were trying to solve with this project?
• What were the Variables that you used to keep track of information?
• What mathematical operations did you perform on your variables? What information did you provide?
• Describe what the physical component of your Micro:bit project was (e.g., an armband, a wallet, a holder, etc.)
• How well did your prototype work? What were you happy with? What would you change?
• What was something that was surprising to you about the process of creating this project?
• Describe a difficult point in the process of designing this project, and explain how you resolved it.
Assessment
4 3 2 1
Variables At least 3 different variables At least 2 variables are At least 1 variable is No variables are
are implemented in a implemented in a meaningful implemented in a meaningful implemented.
meaningful way way way
Variable names All variable names are The majority of variable names A minority of variable names None of the variable
unique and clearly describe are unique and clearly describe are unique and clearly describe names clearly describe
what information values the what information values the what information values the what information values
variables hold. variables hold. variables hold. the variables hold.
Mathematical Uses a mathematical Uses a mathematical operation Uses a mathematical operation No mathematical
operations operation on at least two on at least one variable in a incorrectly or not in a way that operations are used.
variables in a way that is way that is integral to the is integral to the program
integral to the program program
Micro:bit Micro:bit program: Micro:bit program lacks 1 of Micro:bit program lacks 2 of Micro:bit program lacks 3
03.Variables Page 59
Micro:bit Micro:bit program: Micro:bit program lacks 1 of Micro:bit program lacks 2 of Micro:bit program lacks 3
program • Uses variables in a way that the required elements the required elements or more of the required
is integral to the program, elements
• Uses mathematical
operations to add, subtract,
multiply, and/or divide
variables,
• Compiles and runs as
intended,
• Meaningful comments in
code
Collaboration Reflection piece addresses Reflection piece lacks 1 of the Reflection piece lacks 2 of the Reflection piece
reflection all prompts. required elements. required elements. lacks 3 of the required
elements.
03.Variables Page 60
Standards
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as
pair programming, working in project teams, and participating in group active learning
activities
• 2-A-5-7 Create variables that represent different types of data and manipulate their values.
03.Variables Page 61
Conditional Statements
This lesson introduces the Logic blocks such as 'If...then' and 'If...then...else'.
Students practice skills of creativity, problem-solving, and collaboration.
Lesson Objectives
…
• Understand what conditional statements are, and why and when to use them in a program.
• L L 'I ' 'I … '.
• Practice using the Logic blocks so different conditions yield specified outcomes.
• Demonstrate understanding and apply skill by collaborating with classmates to create a
game that uses a micro:bit and a program that correctly and effectively uses conditionals.
Introduction
Computer programs are instructions telling the computer how to process input and deliver
output.
An important part of programming is telling the computer WHEN to perform a certain task.
F , ‘ ’ Conditionals get their name because a certain
Condition or Rule has to be met.
Students are all already familiar with the concept of conditionals in their daily lives!
These are all conditionals! Conditionals follow the format of IF this, THEN that.
IF (condition is met), THEN (action performed)
Have the students share a few conditionals from their own lives with the class or within small
groups.
Note: For older students, you can have them add the ELSE portion of a conditional.
IF (condition is met), THEN (action performed), ELSE (different action performed)
Example:
• IF it is snowing, THEN wear boots, ELSE wear shoes.
The ELSE portion makes sure that a different action is performed in either case. Without the ELSE
04.Conditionals Page 62
The ELSE portion makes sure that a different action is performed in either case. Without the ELSE
action, your students might be barefoot!
Tell the students that they will be acting out some conditionals as though the whole class is a
computer program for a game. Each student will perform a described action if the indicated
condition is met.
Note: This activity can be done as a whole class or in smaller groups or as a pencil and paper
activity.
04.Conditionals Page 63
Unplugged: Red Light Green Light
Objective
To reinforce the programming of basic conditionals by having students experience conditionals
through acting them out in real life.
Activity Overview
Students will line up at one end of the classroom with the goal of reaching the other side of the
classroom. The teacher, and then the students themselves will call out conditionals and all the
students will advance or not depending on the specific conditional statement.
N ‘ ’
running of the program.
Materials
• Pencils and lined paper (if doing this activity seated). Students can advance across the
paper instead of the room with one inch line equal to one step.
Process
• Have the students line up at one side of the room.
• Explain the rules:
○ The object of the game is to get across the room first.
○ F 'I ' I ‘ ’ ,
‘ ’ I ‘ ’ ,
nothing.
○ F 'I ' , , ‘ ’
may apply to you.
After the students get the idea of the game, allow them to make up and call out conditionals
(that meet teacher approval).
They will need to be observant, as a conditional that moves them forward, will also move their
competition forward!
04.Conditionals Page 64
competition forward!
Tips
• SAFETY FIRST! Students, especially younger ones, can get quite silly with this and while it is
meant to be fun and even funny, safety first!
• Student conditionals need to apply to at least two people in the class.
Reflections
H ? W ‘ - ’? D
or fail to correctly carry out the THEN or ELSE action? Were there some conditions that could be
evaluated as something other than True or False (maybe, sometimes)?
Extensions/Variations
• Add AND, OR, AND/OR statements to the conditionals.
I ND , …
• IF’
I , … ,
steps forward.
• Let students create their own conditionals for future program runs with the class. (A very
popular activity, though all conditionals should be run by the teacher first for approval.)
• 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, like writing a sentence or
setting a table or constructing a simple structure.
04.Conditionals Page 65
Activity: Rock Paper Scissors
Introduce activity
• Have students recall the classic rock paper scissors game.
• What are the rules of the game? What are the conditionals?
• Example:
If Player A gets rock, and Player B gets scissors, Then Player A wins.
• Have students write the pseudocode for how to play the game on the micro:bit.
Example pseudocode:
On button A press: choose random number from 0-2
If random number = 0, then display rock icon,
Else if random number = 1, then display paper icon,
Else display scissors icon.
• , ’
check to see if random number = 2. So we just use an else.
Micro:bit
• Working from the specifications, have students work in pairs to try to code a Rock Paper
Scissors game on their own.
• If students get stuck, there is a tutorial at https://pxt.microbit.org/projects/rock-paper-
scissors (steps 1 through 4), that leads students step-by-step through the process of
coding a working rock paper scissor game for their micro:bit.
• Let them play the game against their program.
rock-paper-scissors
04.Conditionals Page 66
04.Conditionals Page 67
Project: Board Game
This is an assignment for students to create a board game. It should take two to three class periods. If your school has a makerspace or an
art classroom where students can access materials such as cardboard, poster paints, or markers, you might schedule your classes to work
there.
Introduction
Many board games use an electronic toy to signal moves, or provide clues. There are some funny examples online if you search for
“ ” H
Dark Tower (featuring Orson Welles): This is an example of a circular board game in which the pieces start on the edges and move in toward
the middle.
Electronic Dream Phone Board Game Commercial - 1992: This board game is really a logic puzzle. There are printed clues that illustrate
relationships and the phone provides clues that help you to narrow down possibilities by a process of elimination.
Stop Thief Electronic Board Game commercial 1979: This board game uses a device to give audio clues that help you to figure out what to
I’
Assignment
Students should work in pairs to create an original board game project in which micro:bit is a central feature, and the rules of their board
game should use Conditionals.
The micro:bit needs to work in conjunction with the game board and/or game pieces and should be a central feature of the game. Ideally, it
should be more than a simple substitute for a six-sided die.
Ideally, students should be writing their own versions of Micro:bit programs to do something original.
Here is one simple program to discuss and use as an example:
04.Conditionals Page 68
let p2 = 0
let p1 = 0
input.onButtonPressed(Button.A, () => {
p1 += 1
basic.showNumber(p1)
})
input.onButtonPressed(Button.B, () => {
p2 += 1
basic.showNumber(p2)
})
input.onGesture(Gesture.Shake, () => {
if (Math.random(p1 + p2 - 1 + 1) + 1 <= p1) {
basic.showString("A")
} else {
basic.showString("B")
}
})
BattleGame
04.Conditionals Page 69
Beta Testing
G ’
• Have each pair of students set up their own project at their table.
• Leave a clipboard or a laptop on the table for taking notes.
• Rotate the students through each project, moving clockwise around the room:
○ Play the game (5 min)
○ Fill out a survey form (5 min)
Many online survey tools will allow you to sort the comments by project and share them with project creators so they can make
improvements based on that feedback.
Reflection
Have students write a reflection of about 150–300 words, addressing the following points:
• Explain how you decided, as a pair, on your particular board game idea.
• What was something that was surprising to you about the process of creating this game?
• Describe a difficult point in the process of designing this game, and explain how you resolved it.
• What feedback did your beta testers give you? How did that help you improve your game? What were the Conditionals that you used
as part of your game rules?
04.Conditionals Page 70
Finished Game
Micro:bit Holder
04.Conditionals Page 71
Game Pieces
let yes_or_no = 0
let current_roll = 0
let previous_roll = 0
input.onButtonPressed(Button.AB, () => {
previous_roll = 0
if (4 <= previous_roll) {
yes_or_no = Math.random(8)
}
if (4 > previous_roll) {
04.Conditionals Page 72
if (4 > previous_roll) {
yes_or_no = Math.random(5)
}
if (2 < yes_or_no) {
basic.showString("YES")
basic.clearScreen()
} else {
basic.showString("NO")
basic.clearScreen()
}
})
input.onGesture(Gesture.Shake, () => {
current_roll = Math.random(6)
basic.showNumber(current_roll + 1)
basic.pause(5000)
basic.clearScreen()
})
input.onButtonPressed(Button.B, () => {
previous_roll += 1
basic.showNumber(previous_roll)
})
input.onButtonPressed(Button.A, () => {
previous_roll += -1
basic.showNumber(previous_roll)
})
basic.showString("SPACE RACE")
previous_roll = 0
SpaceRace
Assessment
4 3 2 1
Rules All game rules are clear and A game rule is missing or More than one game rule Most of the game rules are
complete not complete or not clear is missing or not complete missing or it is not clear
or not clear what the rules are.
Game board Game board is: Game board meets only 3 Game board meets only 2 Game board meets only 1
04.Conditionals Page 73
Game board Game board is: Game board meets only 3 Game board meets only 2 Game board meets only 1
• Complete of the conditions listed for of the conditions listed for of the conditions listed for a
• Neat a score of 4. a score of 4. score of 4.
• Fits with the theme of the game
• Micro:bit is a central part of the
game
Micro:bit Micro:bit program: Micro:bit program lacks 1 Micro:bit program lacks 2 Micro:bit program lacks 3 of
program • Uses the Micro:bit in a way that is of the required elements of the required elements the required elements
integral to the game
• Uses conditionals correctly
• Compiles and runs as intended
• JavaScript includes comments in
code
Photo Complete photo documentation A photo is missing or of Multiple photos and/or Most photos and/or
documentation that includes photos of game poor quality or a caption is captions missing or of captions missing or of poor
board and code and captions. missing. poor quality. quality.
Collaboration Reflection piece includes: Reflection piece lacks 1 of Reflection piece lacks 2 of Reflection piece
reflection • Brainstorming ideas the required elements. the required elements. lacks 3 of the required
• Construction elements.
• Programming
• Beta testing
04.Conditionals Page 74
Standards
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as
pair programming, working in project teams, and participating in group active learning
activities.
04.Conditionals Page 75
Iteration
Lesson Objectives
…
• Understand the value of iteration in programming
• Understand looping as a form of iteration
• L L ‘ ’, ‘ ’, ‘ ’
• Apply the above knowledge and skills to create a unique program that uses iteration and
looping as an integral part of the program
Introduction
In computer programming, iteration is the repetition of a sequence of code. A loop is a form of
iteration. A loop repeats code until a certain condition is met.
Most of us have never read the instructions on a bottle of shampoo, because we already know
how to use shampoo.
If you did read the instructions on a bottle of shampoo, you may read similar instructions as the
‘R ’
How does this one extra step affect the algorithm?
05.Iteration Page 76
I , ‘ ’
I ‘ ’ ‘ ’
no condition that ends the looping.
DBwebsolutions.com
‘R R ’
What other common activities involve repetitive actions? Examples: Singing (choruses repeat),
dancing, school cheers, walking and running, exercise routines...
Optional
‘L ,R ,R ’
05.Iteration Page 77
becomes an industry legend by adding one word to shampoo bottles: REPEAT. He doubles
shampoo sales overnight.
This bit of fiction reflects a small yet significant eddy of U.S. consumer angst: If we REPEAT, are
we or are we not playing into the hands of some marketing scheme? It turns out that in real life
there's a reason you should repeat, or at least there used to be. In the 1950s, when shampoos
began to be mass-marketed, we didn't wash our hair all that often--once or twice a week, as
opposed to five times a week as most of us do now. Also, we used a lot more goop in our hair.
It was the age of Brylcream and antimacassars, remember. Paul Wallace, the director of hair-
care research and development for Clairol, says that when cleaning agents in shampoo came up
against that amount of oil and goop, "it depressed the lather." A second application was
needed to get the suds that consumers expected. Lots of suds mean that hair is already clean.
Maybe too clean (there's no oil to break through), but consumers like it.
FORTUNE asked Frederic Fekkai, the noted and notably expensive New York City hairdresser,
what he thought about the double lather. He says, "Yesterday I put oil on my hair for a different
look and went to a restaurant where the smoke was horrible. This morning I realized I had to do
two shampoos."
At any rate, Wallace says advances in shampoo technology mean that only one application of,
for instance, Clairol's Herbal Essences is sufficient to break through the oiliest hair. The
company has stricken the use of both REPEAT and REPEAT IF DESIRED from all Clairol products.
Yet a lot of brands, like Suave by Unilever and L'Oreal, still say REPEAT. Others, like Unilever's
Finesse and Revlon's Flex, opt for the less imperative REPEAT IF DESIRED. Procter & Gamble
uses REPEAT IF NECESSARY on Pantene.
Getting consumers to wash twice can, of course, increase sales--in ways one might not imagine.
Double sudsing leads to dry hair, Fekkai points out, and that means more beauty products!
"When you do two shampoos, even if you don't usually use a conditioner, you have to use a
little," he says. "The conditioner becomes very important." REPEAT. FOLLOW WITH
CONDITIONER. Words Cheever's marketer could have retired on.
--Lauren Goldstein
05.Iteration Page 78
Unplugged: Walk a Square
Objective
To reinforce the concept of iteration by having students act out the repeated steps of an
algorithm in real life.
Overview
Students will give the teacher instructions to do a simple activity, then look for places where
using iteration could shorten their code and make it more efficient.
Process
• Place a chair in the front of the room.
• Stand at the back right side of the chair facing the students.
• Ask the students what instructions they could give you that when followed would lead you
to walk around the chair, ending up just as you started. You may want to demonstrate
what this would look like by walking around the chair.
• Tell the students you can only process one instruction at a time, so their algorithm needs
to be step-by-step.
• As students suggest instructions write them on the board or wherever everyone can see
them.
Their pseudocode will probably end up looking something like this:
1) Step forward
2) Turn left
3) Step forward
4) Turn left
5) Step forward
6) Turn left
7) Step forward
8) Turn left
05.Iteration Page 79
B ’ !
just three lines of code. If they have not noticed already, have students look for places
where the code repeats.
• Tell them that whenever you have code that repeats, you have an opportunity to use a
loop to simplify your code.
• Prompts:
○ What lines are repeated? 1) Step forward. 2) Turn left.
○ How many times are they repeated? Four
○ So how could we rewrite this code? Students will suggest a version of the following:
Repeat 4 times:
1) Step forward
2) Turn left
There! They have just rewritten eight lines of code as three lines of code, by using a loop.
‘ ’
of times until a condition is met. The condition in this algorithm is that the code in the loop is
repeated 4 times. Once this condition is met, the program exits the loop.
This is a great opportunity to have the students think of the benefits of having fewer lines of
code. Some possible reasons: Less typing, saves time, fewer chances of making a mistake, easier to
read the code, fewer lines of code to debug...
Notes
• Depending on the particular class, you can make this exercise more challenging, by
requiring the students to be more specific in their instructions.
For example: Step forward 14 inches (you can have students actually measure the exact
, 9 …
05.Iteration Page 80
Activity: Loops Demos
To start, the students can code the same algorithm they created in the unplugged activity using
a loop.
‘Repeat’ block
Code a Sprite to walk a square. Have students click on the Loops category in the Toolbox, and
look at the three choices available.
‘ ’ !H
W ’ parameter.
A parameter is a type of variable used as input to a function or routine. In this case, the
parameter tells the repeat block how many times we want the code within the block to repeat.
F , ’
• Click on the Advanced category in the Toolbox. This will open up a more advanced menu
of blocks.
• G , ‘ ’
05.Iteration Page 81
• W ’ G R ‘W q ’
pseudocode, see if the students can find the blocks they need for moving their sprite and
turning their sprite.
• D ‘ ’ ‘ ’
• They now have these blocks in their coding workspace.
• F , ‘ ’
05.Iteration Page 82
N ’
event handlers.
• On start, we want the sprite to appear. To make this happen, go to the Variables menu and
‘ ’
• ‘ ’ ‘ ’
• ‘ ’ ‘ ’
You should now see the sprite appear in the top left of the microbit simulator.
• , ‘ ’
the Input menu.
• ‘ ’ ‘ ’
• ‘ ’ ‘ ’
• ‘ ’ ‘ ’ ‘ ’
input.onButtonPressed(Button.A, () => {
for (let i = 0; i < 4; i++) {
item.move(4)
item.turn(Direction.Right, 90)
}
05.Iteration Page 83
}
})
Go ahead and run the program. Make the sprite move by pressing button A.
Slo-Mo
A helpful feature of Microsoft MakeCode is "Slo-Mo", or slow-motion mode.
• Click on the snail icon under the micro:bit simulator.
This will slow down the execution (running) of the program, and highlight parts of your code so
you can see step-by-step, which line of code is being processed.
Now run your program several more times. Do you see the different lines of your code
highlighted as the program runs? Do you see the sprite move?
Slo-Mo in Blocks
Slo-Mo in JavaScript
So, the code is running and the sprite is moving! Sometimes we forget just how fast computers
‘ ’ ,
right after each time the sprite moves. This will give our human eyes a chance to see it move.
05.Iteration Page 84
right after each time the sprite moves. This will give our human eyes a chance to see it move.
WalkaSquare
05.Iteration Page 85
Run your program again. Now we can see the sprite move. It still moves pretty quickly, but at
least we can see it move.
If there is time, let the students experiment with changing the parameters to see how these
changes affect their program.
We just used the first of the 3 different types of Loop blocks available to us. What about the
,‘ ’ ‘ ’?
L ’ ,
Our pseudocode for the first row might look like this:
Turn led x:0, y:0 on
Pause
Turn led x:0, y:0 off
Pause
Turn led x:1, y:0 on
Pause
Turn led x:1, y:0 off
Pause
Turn led x:2, y:0 on
Pause
Turn led x:2, y:0 off
05.Iteration Page 86
Turn led x:2, y:0 off
Pause
Turn led x:3, y:0 on
Pause
Turn led x:3, y:0 off
Pause
Turn led x:4, y:0 on
Pause
Turn led x:4, y:0 off
’ ,
• What is the only variable that is changing in this pseudocode? The value of the x
coordinate.
• How much is the value of the x coordinate changing each time? The value of the x
coordinate is changing by 1 each time.
• What is the range of values for the x coordinate? The range of values for the x coordinate
is 0 through 4.
N ’ !
• F L , ‘ ’
• ’ , , xindex.
• W ’ F L ,
a 'plot' block and an 'unplot' block to the coding workspace.
• F B , ‘ ’
• ‘ ’ ‘ ’ , ‘ ’ , ‘ ’
block, the second 'pause' block.
• ‘ ’
L ’
• ‘ ’ ‘ ’ ‘ ’
• Change the value of the x coordinates in the plot and unplot blocks to this same variable.
05.Iteration Page 87
let index = 0
basic.forever(() => {
for (let xindex = 0; xindex <= 4; xindex++) {
led.plot(xindex, 0)
basic.pause(100)
led.unplot(xindex, 0)
basic.pause(100)
}
})
We can use the default values for the rest of the parameters.
You should now see a light moving from left to right along the top row of the micro:bit
simulator.
To make our pattern continue through all the leds, we can change the value of the y coordinate
as well.
To do this efficiently, using the fewest lines of code, we can even put a loop inside a loop. Loops
inside other loops are known as nested loops.
• So that we can change the value of the y coordinate, make a new variable, named yindex.
• D ‘ ’ L
• ‘ ’ ‘ ’ ,
• ‘ ’ ‘ ’ ‘ ’
• Change the value of the y coordinates in the plot and unplot blocks to this same variable.
05.Iteration Page 88
let index = 0
let yindex = 0
basic.forever(() => {
for (let yindex = 0; yindex <= 4; yindex++) {
for (let xindex = 0; xindex <= 4; xindex++) {
led.plot(xindex, yindex)
basic.pause(100)
led.unplot(xindex, yindex)
basic.pause(100)
}
}
})
There! With only a half dozen or so lines of code, we have made our light travel through all the
coordinates on the micro:bit screen.
Here is what is happening to the values of the x & y coordinates as the program steps through
each line and loop inside the forever block:
1. In the outer of the two for loops, the value of the y-coordinate is set to 0.
2. The nested inner loop then sets the value of the x-coordinate to zero.
3. The corresponding led (x:0, y:0) is plotted and then unplotted.
4. Then the value of the x-coordinate is increased by 1 and step #3 runs again with the
coordinates now (x:1, y:0).
5. Then the value of the x-coordinate is increased by 1 again and step #3 runs again with the
coordinates now (x:2, y:0).
6. The inner loop keeps running like this until it has completed its loop with the value of the x
coordinate now 4.
7. With the inner loop complete, the program now runs the second iteration of the outer
loop, increasing the value of the y-coordinate by 1, then back to the inner loop which runs
4 more times stepping through values for x from 0 through 4.
Have the students use the Slo-Mo mode to watch the program step through the loops.
• By the end of the program run, how many times has the inner loop executed? 25
• Other than knowing that there are 25 LEDs and each is lit up once, how can you figure this
out? The outer loop loops 5 times altogether, once for every value of the y coordinate from 0
through 4. Each time the outer loop runs, the inner loop runs 5 times, once for every value of
the x coordinate from 0 through 4. 5 runs of the outer loop x 5 runs of the inner loop = 25
times the inner loop executes.
Mods
• If there is time, let the students experiment with changing the parameters to see how
these changes affect their program.
• What happens if you switch the positions of the nested loops, so the outer loop loops
through the xindex values and the inner loop loops through the yindex values?
• W ‘ ’ ‘ ’ ?
05.Iteration Page 89
‘While’ block: Micro:bit Alarm!
The while block is useful when you want your program to loop until a certain event happens or a
different condition is met.
For example, maybe you want an alarm to sound if someone shakes your micro:bit!
In order to turn the alarm off, you press the button A. Until you press the button, the alarm
should continue to sound!
Y ' ' ‘ ’
input.onGesture(Gesture.Shake, () => {
while (!(input.buttonIsPressed(Button.A))) {
for (let i = 0; i < 2; i++) {
music.playTone(262, music.beat(BeatFraction.Half))
music.playTone(523, music.beat(BeatFraction.Half))
}
}
})
Alarm
05.Iteration Page 90
• Can you read what this code does?
• Can you write out pseudocode that describes what this code does?
Example Pseudocode:
When someone shakes the microbit, while button A is not pressed, play the two tone alarm twice.
Keep playing the alarm tones until the user presses the A button.
To use sound with your micro:bit, you will need to connect it to some speakers or headphones.
See how to do this here: https://pxt.microbit.org/projects/hack-your-headphones
05.Iteration Page 91
Project: Get Loopy!
There are many different ways to use the three types of loop blocks.
Recall the different common repetitive actions you thought of back at the beginning of this
lesson.
• How will you use loops to create something useful, entertaining, or interesting?
• What might you make?
Example
05.Iteration Page 92
micro:bit Hat Man - inside
This project uses the micro:bit light sensor to display a happy face when it is sunny, and a
frowning face when it is dark. The micro:bit is connected to a servo mounted on the inside of
the container, and the smile and frown are attached to plastic coffee stirrers with tape and hot
glue.
Reflection
Have students write a reflection of about 150–300 words, addressing the following points:
• Explain how you decided on your particular "loopy" idea. What brainstorming ideas did
you come up with?
• What type of loop did you use? For, While, or Repeat
• What was something that was surprising to you about the process of creating this
program?
• Describe a difficult point in the process of designing this program, and explain how you
resolved it.
• What feedback did your beta testers give you? How did that help you improve your loop
demo?
Assessment
05.Iteration Page 93
Assessment
4 3 2 1
Loops At least 3 different At least 2 loops are At least 1 loop is No variables are
loops are implemented in a implemented in a implemented.
implemented in a meaningful way meaningful way
meaningful way
Variables All variable names The majority of A minority of None of the
(parameters) are unique and variable names are variable names are variable names
clearly describe unique and clearly unique and clearly clearly describe
what information describe what describe what what information
values the variables information values information values values the
hold. the variables hold. the variables hold. variables hold.
Sound, Uses sound, Uses a only two of Uses a only one of None of the
display, and display, and the required the required required
motion motion in a way element in a way element in a way elements are
that is integral to that is integral to that is integral to used.
the program the program the program
Micro:bit Micro:bit Micro:bit program Micro:bit program Micro:bit
program program: lacks 1 of the lacks 2 of the program lacks 3
• Uses loops in a required elements required elements or more of the
way that is required
integral to the elements
program
• Compiles and
runs as intended
• Meaningful
comments in
code
Collaboration Reflection piece Reflection piece Reflection piece Reflection piece
reflection includes: lacks 1 of the lacks 2 of the lacks 3 of the
• Brainstorming required elements. required elements. required
ideas elements.
• Construction
• Programming
• Beta testing
05.Iteration Page 94
Standards
• CL.L3A-03 Explain how sequence, selection, iteration, and recursion are building blocks of
algorithms.
05.Iteration Page 95
Introduction
In this unit, we will be reviewing the concepts we covered in the previous weeks, and providing
“ - ”
We will also introduce a framework for keeping students accountable to the work they are doing
individually and in groups, and providing a rubric for assessment of the development process, as
well as the finished product.
It is important to allow students to practice accounting for the work they are doing on a short
“ - ” ,
weeks, it will be easier for you to keep track of what everybody is doing.
It also reinforces the important idea that how you solve problems is at least as important to
learning as whether you solved them at all (or even got the right answer). Programming is a
process of patient problem-solving, and finding ways to value, acknowledge, and reward the
problem-solving process is an important part of assessment.
06.Mini-Project Page 96
Review
Making
The micro:bit is very effective at bringing real things to life. It can be supported in a cardboard holder, attached to a
wand, or even sewn into fabric. The design thinking process is a helpful way to gather more information about the
person who will be using whatever you are designing.
Variables
Variables store information so that it can be accessed or referenced later. Some variables hold information that
changes, and some hold information that stays constant. It is important to name your variables with something that
explains what type of information it holds. Using variables in your code allows you to create algorithms that use
mathematical operations to perform the same calculations every time, even when the values of your variables are
different.
Conditionals
Conditional statements tell the computer when to do something. They are used to create branches, or decision points,
where a program can choose one path or the other based on the values of certain variables, or based on data from the
’
order for the enclosed statements to run.
06.Mini-Project Page 97
Project: Mini-Project
This project takes approximately a week to complete. Most of that time is spent working on the project in a
makerspace or art classroom.
The mini-project is an opportunity for students to design a project that serves a purpose by solving a problem or
filling a need. It is also an opportunity to do two things:
• Show what you know
• Learn something new
Ideally, there should be a maker component to this project. This is a real world component that works with the code
on the micro:bit to do something unique.
Students are asked to each propose an original independent project. Students are allowed to work on the same idea,
but they cannot turn in the same code. They can, and should work collaboratively, solving the same kinds of
problems together, but the projects they turn in should be unique and original.
We find that a "science fair" type of setup works well here, with students stationed at their own tables, showing off
and demonstrating their project. An event like this works well for these reasons:
• A real world audience for the work students have done can be very motivating
• It is a chance for people who are not familiar with the micro:bit to appreciate the finished product
• It provides good feedback to students about how someone interacts with their product
• It is a chance to have real conversations with the people behind the product, rather than just viewing the
product on display by itself
• Finally, and most importantly, it is a chance to bring the community together to celebrate the great work all of
your students have done!
Assignment
• Create an original project using the micro:bit.
• Incorporate a physical component to the project.
• Demonstrate the use of one of the following concepts:
○ Input / Processing / Output
○ Variables
○ Simple Circuits
○ Iteration/Loops
○ Conditional Statements
Project Ideas
• “N I ”F
• Make a Moving Monster
• Make a musical instrument
• Fishing Game
• Make an Air Guitar (uses while loop to do tempo and pitch)
• Screensaver
• Screensaver that uses other inputs to draw
Interactive book
06.Mini-Project Page 98
• Interactive book
• Binary Clock or some other way to represent numbers visually
Examples
06.Mini-Project Page 99
This is a skill game in which tennis balls are thrown underhand at one of the three rings, which are lined with
aluminum foil so they complete a circuit underneath when the ball makes contact with the ring.
micro:bit Storybook
This is a prototype of a storybook that could use the micro:bit to display animations for part of the story. Copper
tape is used on the underside of the paper flaps to make contact between the GND pin and each of the other pins in
sequence.
Work Logs
Because students are working on the projects in class, and much of the benefit comes from working together to solve
problems, they should account for the work they are doing by writing a work log.
, , I ’
more than thirty seconds or so to write up a work log. Students should do one for every class. A shared Microsoft
OneNote notebook is a great way to keep a work log that students can update regularly. Alternately, you might use a
collaborative shared document, or your classroom management system, or even e-mail.
Reflection
At the end of the week, students should compose a final reflection that summarizes the process of their learning over
the course of the week. They should go back through their work logs and talk about the following:
• Talk about one challenge you faced in creating this project, either a challenge in coding or in making the
artifact. How did you overcome this challenge?
• What did you demonstrate that you already knew?
• What was the new thing you learned in order to make this? How did you learn about it?
• Who in the class provided help to you along the way? How?
• Describe one specific thing you are proud of in this project.
• What would you do differently next time?
• If you had another week to work on this project, what might you add or improve?
Assessment
4 3 2 1
Code - Code very effectively Code only partially Code only partially Code does not
Show what you demonstrates the use of previous demonstrates demonstrates demonstrate
know concept(s). Variable names are previous concepts, previous concepts, previous concepts,
unique and clearly describe what and/or is not and/or is not is not efficient,
information values the variables efficient. efficient, variable variable names not
hold. Code is highly efficient. names not clear. clear.
Code - Code very effectively Code only Code only Code does not
Show something demonstrates the use of new minimally minimally demonstrate new
new concept(s). Variable names are demonstrates new demonstrates new concepts, is not
unique and clearly describe what concepts, and/or is concepts, and/or is efficient, variable
information values the variables not efficient. not efficient, names not clear.
hold. Code is highly efficient. variable names not
clear.
Maker Tangible component is tightly Tangible Tangible No tangible
component integrated with the micro:bit and component is component does component
each relies heavily on the other to somewhat not add to the
make the project complete. integrated with the functionality of the
micro:bit but is not program.
essential.
Work Logs All work logs submitted on time, One late or missing Two late or missing More than two late
and accurate work log and/or work logs and/or or missing work
Teachers want their students to collaborate on projects but they also want to be able to hold them accountable
for getting their work done. Many teachers struggle with assessing exactly how much each individual contributed
, “ ”
The Mini-Project (and the Final Project) are not group projects. Students are asked to propose their own
independent project and are expected to get it done. But they are not on their own in this process! We build in
frequent opportunities for students to collaborate and share the collective knowledge of the class as they go. We
“ ”
Beginning of class
For groups of 15 or so, have students each briefly (no more than 30 seconds or so) report on their progress in
front of the group:
• One-line description of project
• Their progress so far
• Something they are going to work on figuring out today
It is important that everyone else is listening to each project and volunteering their help or solutions if they are
figuring out the same thing or if they have solved that problem in a previous class.
Example:
I’m working on a pinball machine. So far I have done the board and the ramp. Today I am going to be working
on wiring the bumpers so that when the ball hits the bumper, the micro:bit detects it and displays the score.
Ideally students who are working on projects should be aware of what other students are working on and what
they are figuring out. It creates more opportunities for collaboration in the classroom and can encourage
students to seek help from each other rather than all waiting in line to talk to you.
I’ ’ F
15 or 20 students, you may want to split them into two or three larger groups and have them report out to each
other.
During Class
End of Class
, “ -in- ” G
students together and have them move from table to table while each student presents one thing that he or she
figured out during the class. This is really an informal presentation, and it is understood that it is not finished at
; “ ”B ,
one throughout the classroom, almost like physicians making rounds in a hospital. This is an important way to
, “ - ” q
Work-in-progress reports should be short, no more than twenty or thirty seconds. If you have a large class, you
might divide the class into several large groups and have them present to each other.
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as
pair programming, working in project teams, and participating in group active learning
activities.
This lesson introduces the use of coordinates to store data or the results of mathematical operations. It gives
students practice programming for the LEDs of the micro:bit screen using coordinates. And introduces the basic
game blocks of MakeCode.
Lesson Objectives
…
• Understand that the 5 x 5 grid of LEDs on the micro:bit represent a coordinate grid with the origin (0,0) in
the top left corner.
• Understand that the values of the x coordinates range from 0 through four and increase from left to right.
• Understand that the values of the y coordinates range from 0 through four and increase from top to bottom.
• Learn how to refer to an individual LED by its x & y coordinates.
• Learn how to plot (turn on) and unplot (turn off) individual LEDs and how to toggle between these two
states.
• Learn how to check the current on or off status of an individual LED as well as check and set the brightness
level.
• Apply the above knowledge and skills to create a unique program that uses coordinates as an integral part
of the program.
Introduction
Through math class, most middle school students are already familiar with coordinate grids and mapping x and y
coordinates on a plane. To review some terms:
Axes
○ The basic coordinate grid a student learns has two axes,
▪ an x-axis which runs horizontally and
▪ a y-axis which runs vertically.
Origin
○ These two axes meet at a point called the origin where both the x and the y values are zero.
○ On this basic coordinate grid, the origin is in the lower left corner of the grid and has the coordinates
(0,0).
Coordinate pair
○ The first value in a coordinate pair is the x value and the second value in a coordinate pair is the y
value.
○ A simple way to remember which value comes first is to remember their order in the alphabet. The
letter x comes before the letter y in the alphabet and the x coordinate comes before the y coordinate in
a coordinate pair.
It is important however that the students understand the two major differences between the micro:bit LED grid
and the coordinate grid that they are used to using in math class:
• the origin (0,0) is in the top left corner.
• the values of the y coordinates range from 0 through four and increase from top to bottom.
Note:
• The values of the x coordinates range from 0 through four and increase from left to right just as they do in
the coordinate grids used in math class.
René Descartes (1596-1650), was a French philosopher and mathematician who developed the coordinate system
we use today. A story goes that while lying in bed, he noticed a fly on the ceiling. In wondering how he could
’ ,
’
horizontally and then vertically to reach the fly. His coordinate system proved useful in many ways including
creating an important link between the studies of algebra and geometry. Geometric shapes could now be
described by points on a coordinate plane.
The game Battleship is perhaps the most fun a student can have practicing using a coordinate
grid. The original Battleship game is a 10x10 grid with numbers on one axis and letters on the
other.
To help us practice using the correct coordinates for the grid of micro:bit LEDs, let the students
play a smaller 5x5 version of Battleship using x and y coordinates instead of letters and
numbers.
Have students make their own sets of 5x5 grids to reinforce the layout of the micro:bit grid.
Each student should make two grids. One grid is for placing their own ships and keeping track
’
’
’ ’
misses.
(0,0) (1,0) (2,0) (3,0) (4,0)
(0,1) (1,1) (2,1) (3,1) (4,1)
(0,2) (1,2) (2,2) (3,2) (4,2)
(0,3) (1,3) (2,3) (3,3) (4,3)
(0,4) (1,4) (2,4) (3,4) (4,4)
O ’ ’
ships.
(0,0) (1,0) (2,0) (3,0) (4,0)
(0,1) (1,1) (2,1) (3,1) (4,1)
(0,2) (1,2) (2,2) (3,2) (4,2)
(0,3) (1,3) (2,3) (3,3) (4,3)
(0,4) (1,4) (2,4) (3,4) (4,4)
Then pair the students to play against a partner. Each student's ships are hidden somewhere on
their 5x5 grid. Students should be taking turns calling their shots using x and y coordinates, in
the proper order. Their opponent will use those coordinates to plot the location of their shots.
If a hit is recorded on a ship, then you say, "Hit". If the shot misses, you say, "Miss". If the entire
length of a ship is hit, it is sunk and removed from play. Tradition dictates that the player
announces, "You sank my battleship!"
Since their grid is only one quarter the size of the original Battleship grid, students can use fewer
and smaller ships. For example, they could play with 3 ships, one each of size 3, 2, and 1.
The game can be played with just paper and pencils or you could use small tokens and markers,
Notes
• ’
again with white board (dry erase) markers.
• The official rules of Battleship are easily found on the internet. Modify them as needed for
your particular class.
Guide the students to create programs using coordinates and LEDs. Each of these short exercises demonstrates
how to use coordinates to control the LED ’
more complex projects.
• Smile animation - A short exercise in plotting and toggling LEDs to create a simple animation.
• Random Patterns generator - A short exercise using a loop to generate random LED patterns and then
checking the status of a specific LED.
• Brightness - A short exercise in using the brightness settings for the micro:bit LEDs.
Smile Animation
A short exercise in plotting and toggling LEDs to create a simple animation.
• Though students can use the 'show leds' block for images and animation, there is another way to tell the
micro:bit what LEDs to turn on and off using coordinates.
• We can still use the 'show leds' block to plan which LED coordinates to turn on
• Drag out a couple 'show leds' blocks from the Basic Toolbox drawer.
• Create a smiling face and a non-smiling face.
• From the LED Toolbox drawer, drag out 6 'plot x y' blocks.
○ Tip: you can also right-click on a block and select Duplicate to copy blocks
• Have the students compare the two face images and determine which LEDs are on in both images.
• Plot these LEDs using the correct (x,y) coordinates.
• When done, place these 'plot x y' blocks inside an 'on start' block.
led.plot(1, 0)
led.plot(3, 0)
led.plot(2, 1)
led.plot(1, 3)
led.plot(2, 3)
led.plot(3, 3)
Now we can code for the 4 LEDs that change back and forth, on and off, as we switch from one face to the other
• From the LED Toolbox drawer, drag out 4 'toggle x y' blocks.
• Replace the default values with the correct (x,y) coordinates.
The 'toggle x y' block will change the status of an LED from on to off or off to on.
• Place these 4 'toggle x y' blocks in a 'forever' block.
• Place the two 'toggle x y' blocks that create the smile first, followed by the two 'toggle x y' blocks for the
non-smile.
• Y q L ’ ' '
between the two pairs of 'toggle x y' blocks. Set the pause value to 250 milliseconds.
basic.forever(() => {
led.toggle(0, 2)
led.toggle(4, 2)
basic.pause(250)
led.toggle(0, 3)
led.toggle(4, 3)
})
led.plot(1, 0)
led.plot(3, 0)
led.plot(2, 1)
led.plot(1, 3)
led.plot(2, 3)
led.plot(3, 3)
SmileAnimation
input.onButtonPressed(Button.A, () => {
basic.clearScreen()
for (let index = 0; index <= 4; index++) {
input.onButtonPressed(Button.A, () => {
basic.clearScreen()
for (let index = 0; index <= 4; index++) {
led.plot(index, Math.random(5))
}
})
input.onButtonPressed(Button.B, () => {
if (led.point(0, 0)) {
basic.showIcon(IconNames.Yes)
} else {
basic.showIcon(IconNames.No)
}
})
RandomPatterns
Brightness
A short exercise in using the brightness settings for the micro:bit LEDs. Important to note - the brightness level of
the micro:bit simulator LEDs will NOT appear to change! You must run your program on the actual micro:bit to
see the different brightness levels.
We will check on, and numerically display the brightness level with our program, so we can verify with the
simulator that it is working.
Pseudocode:
W ’ LEDs to the highest level on start and then use on button A pressed to
B W ’ +B
pressed to check and display numerically the current brightness level.
Steps:
• Drag 3 'set brightness' blocks and 3 'brightness' blocks from the Led - More Toolbox drawer onto your
coding workspace
• Place one 'set brightness' block in the 'on start' block
• Add a 'show icon' block after the 'set brightness' block so we will have an image to look at
• From the Input Toolbox drawer, drag out 3 'on button pressed' blocks onto your coding workspace
• Leave one 'on button pressed' block with the default setting of A and change the second one to B and the
third one to A+B
• Place one 'set brightness' block in the 'on button A' pressed block, and the other 'set brightness' block in
the 'on button B' pressed block
• From the Math Toolbox drawer, drag out an addition block and a subtraction block
• Place the addition block within the 'set brightness' block in the 'on button B pressed' block
• Place the subtraction block within the 'set brightness' block in the 'on button A pressed' block
• Place a 'brightness' block on the left side of each math expression
• Change the default value of 0 on the right side of each math expression to 25
input.onButtonPressed(Button.A, () => {
led.setBrightness(led.brightness() - 25)
})
input.onButtonPressed(Button.B, () => {
led.setBrightness(led.brightness() + 25)
})
, ’
• O +B , ’
• ’ -display the image we used on start.
input.onButtonPressed(Button.A, () => {
Brightness
Try it out!
• What happens if adding 25 or subtracting 25 from the current brightness level would result in a sum or
difference outside of the 0 to 255 brightness range?
Use what you now know about LEDs, coordinates, and brightness to create your own project: a screensaver, or a
game. You should find a way to use coordinates in your program. Even better, use variables to store and update
your coordinates.
Screensavers
One type of project is a screensaver. A long time ago, computers and televisions used cathode ray tube (CRT)
screens for displays. The glass screen of the display was coated on the back with phosphor, a substance that
glows when painted with electrons from an electron gun at the other end of the tube. When the same area of the
screen was painted (excited) over and over again by the stream of electrons, that part of the screen would
sometimes "freeze" with the same image, burned into the phosphor for good. This was called "burn-in".
Normally, if a show was running, or if someone was actively using the computer, the display changed often
enough that burn- ’
would run whenever the screen was idle. Today, nearly all computers and television sets use LCD displays, which
are not affected by burn-in. But you can still find a screen saver in nearly every computer's Settings panel, as an
opportunity to show off some neat graphics or animation.
1) A "screen saver" animation using the plot/unplot blocks. You can fill the screen line by line, pausing
between each one, or fill it with a random constellation of stars.
OR
1) A game that uses sprites to manage the x and y coordinate values of the different objects.
Your project might use variables to store the values of sprites, which are special structures that contain an x and a
y coordinate together that describe the sprite's location as one LED on the screen.
Project Ideas
Firework Screensaver
This project uses a for loop with the plot/unplot blocks to create a symmetrical design on the screen. This student
used a subtraction operation to get a variable that decreases as the index variable in the loop increases.
Firework
Cascade
DodgeBall
Reflection
Have students write a reflection of about 150–300 words, addressing the following points:
• Did you do a screensaver? A game? Something different? How did you decide?
• If you did a game, what is the object of the game?
• How does your project use coordinates?
• Describe something in your project that you are proud of.
• Describe a difficult point in the process of designing this program, and explain how you resolved it.
• What feedback did your beta testers give you? How did that help you improve your design?
Assessment
4 3 2 1
Coordinates Uses at least 3 of the At least 2 of the At least 1 of the No plot/unplot/
and LEDs different kinds of plot/ different kinds different kinds toggle/point x y
unplot/toggle/point x y of plot/unplot/ of plot/unplot/ blocks are
blocks in a meaningful toggle/point x y blocks toggle/point x y blocks implemented.
way. in a meaningful way in a meaningful way
Uses variables to update
coordinates.
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as
pair programming, working in project teams, and participating in group active learning
activities
• 2-A-5-7 Create variables that represent different types of data and manipulate their values.
This lesson introduces the use of the boolean data type to control the flow of a program, keep
track of state, and to include or exclude certain conditions.
Lesson Objectives
…
• Understand what booleans and boolean operators are, and why and when to use them in a
program.
• Learn how to create a boolean, set the boolean to an initial value, and change the value of
the boolean within a micro:bit program.
• Learn how to use the random true or false block.
• Apply the above knowledge and skills to create a unique program that uses booleans and
boolean operators as an integral part of the program.
There are several different data types used in computer programming. We have already used
two of these types:
• String (for text)
• Integer (for numbers)
Boolean is another type of data. A boolean data type has only two values: true or false.
In true binary fashion, these two values can be represented by the numbers 1 = true, and 0 =
false.
Ask the students to think of things in daily life that have only two values or states. The status is
always one value or the other value.
Note:
Arguments can be made that some of these can have more than two values.
For example: At the store, you may have brought your own reusable bags or pay by check.
Let the students discuss these to help them hone in on which examples best represent Booleans.
A student might argue that a dimmer switch on a light or the brightness value on the micro:bit
LEDs allow the lights to be in a state between on and off. One could respond that you can
‘ ’
electricity at all (off).
In programming, if you have worked with conditionals or loops, you have already worked with
this type of logic:
• If a certain condition is true, do this, otherwise (if condition is false), do something else.
• While a certain condition is true, do this
L ’
AND
(Condition A AND Condition B)
For this expression to evaluate as true, both conditions in the expression need to be true.
So, if both Condition A AND Condition B are true, the expression will evaluate as or return true.
OR
(Condition A OR Condition B)
For this expression to evaluate as true, only one of the conditions in the expression needs to be
true.
If Condition A is true, the expression will return true regardless of whether Condition B is true or
false.
If Condition B is true, the expression will return true regardless of whether Condition A is true or
false.
NOT
NOT can be used when checking that a condition is false (or not true).
For example:
• (NOT Condition A and Condition B) evaluates as true only if Condition A is false and
Condition B is true.
• (Condition A and NOT Condition B) evaluates as true only if Condition A is true and
Condition B is false.
• (NOT Condition A and NOT Condition B) evaluates as true only if both Condition A and
Condition B are true.
NOT is also useful when using a loop. For example, you can use a NOT to check
W NO , …
N ‘F ’ q ‘NO ’
Sidebar material
George Boole (/ˈbuːl/; 2 November 1815 – 8 December 1864) was an English mathematician,
educator, philosopher and logician. He worked in the fields of differential equations and
algebraic logic, and is best known as the au`thor of The Laws of Thought (1854) which contains
Boolean algebra.
Most students have used a penny to decide something. Ask for some examples.
Who goes first in a game, to break a tie, to decide which activity to do…
A simple penny is the most common binary decision making tool ever!
When you flip a coin to decide something there are only two possible outcomes, heads or tails.
When you flip a coin the outcome is random.
H ’ …
In a double coin toss, both people have a coin and they flip the coins at the same time.
Working in pairs, have the students make a table or list of the possible outcomes if each student
flipped a coin at the same time.
Example:
Coin A Coin B
Heads Heads
Heads Tails
Tails Heads
Tails Tails
So, if 2 coins are flipped, the chance that the outcomes will be the same (HH/TT) is equal to the
chance that the outcomes will be different (HT/TH). Both outcomes, coins the same/coins are
different have a 2 in 4 or 50% chance of occurring.
Therefore, if Person A wins each time the outcomes are the same and Person B wins each time
the outcomes are different, both have an equal chance of winning each double coin flip. With
Example:
Coin A Coin B Totals
Heads Heads
Heads Tails
Tails Heads
Tails Tails
Just for fun, have them play to a certain total number of rounds.
L ’ !
Have the students copy their Heads/Tails table of possible outcomes, but label the columns
" H " " BH " ‘H ’ ‘ ’ ‘ ’
‘F ’ In the study of logic, this is known as a truth table.
W ’ ,
of each outcome.
Can we make this code more efficient? Can we combine any of these lines?
Try using an OR to combine both conditions in which Player A scores a point.
Note: Just as you do for math expressions with multiple operators, use parentheses to make it
clear how the conditions and statements are grouped together.
The students are by now familiar with the MakeCode blocks. As they think through their
algorithms, they may even have started to visualize the blocks they might use. Visualizing the
blocks as they pseudocode can help them with the logical steps of their program. It can also
help them to visualize and recognize the big picture of their code as well as the details.
Using blocks to start coding these two conditionals as currently written, might look like this:
, ’ I
L ’
‘I H ’ ‘I H = ’ W
simplify our code.
Instead of:
, ‘I H ’ ‘I H =F ’,
instead of
we can code
So now we have
What about our other big block of code for the conditions for a Player B win?
We could simplify that to
Random Functions
We use a coin flip to decide things because the result is random, meaning the result happens
without any conscious decision or direction. We use dice and game spinners for the same
reason. The results are not predetermined or directed in any way.
So, how do we get a random flip in code? Most computer programming languages have a built
in function that will select a random number given a range of values. Microsoft MakeCode has a
block for this. And it also has a block for getting a random true or false value.
We will call on this built in function to get a random true or false value for each flip of a coin in
the next Activity.
Our basic pseudocode for our Double Coin Flipper could look like this:
1. Use the random function to get a true/false value for Coin A.
2. Use the random function to get a true/false value for Coin A.
3. Compare the current values of Coin A and Coin B.
4. I B , ’
score.
5. Otherwise, the current true/false values of Coin A and Coin B must be different, so add a
B’
6. When players are done with their double coin flipping, show the final scores for each
player.
Guide the students to create a program using Boolean variables and operators.
W ’
F , ’
Make a variable for each of the following:
• CoinAHeads
• CoinBHeads
• PlayerAScore
• PlayerBScore
The initial value of a variable is the value the variable will hold each time the program starts.
By default:
• z “”
• a number variable is initialized to 0
• B z ‘ ’
I z z B ‘ ’
You can find the false blocks under the Logic menu.
Notice that we also added an image for the start screen, so the user knows the program has started and is ready.
Does the image look like two coins?
• From the Input Toolbox drawer, drag an 'on shake' block to the coding workspace
• From the Variables Toolbox drawer, drag 2 'set' variable blocks to the coding workspace
• Drag the 2 'set' blocks into the 'on shake' block
• ‘ ’ H BH
• From the Math Toolbox drawer, drag 2 'pick random true or false' blocks to the coding workspace
• Hover over this 'pick random' block and note that its pop-up description mentions coin flipping!
Now that the virtual CoinA and CoinB have been virtually flipped, we need to compare the outcomes to see if
they are the same or different.
• From the Logic Toolbox drawer, drag an 'if...then...else' block to the coding workspace
• Drag the 'if...then...else' block into the 'on shake' block under the 'set' variable blocks
input.onGesture(Gesture.Shake, () => {
CoinAHeads = Math.randomBoolean()
CoinBHeads = Math.randomBoolean()
if (true) {
} else {
}
})
Now our logic block is ready for the next steps of our pseudocode.
1. Compare the current values of Coin A and Coin B.
2. I B , ’
3. O , B , B’
Because we were able to visualize our blocks as we wrote our pseudocode, we already know what blocks we will
use and also know that we have simplified our code as much as possible!
, ’ ’
let PlayerBScore = 0
let PlayerAScore = 0
let CoinBHeads = false
let CoinAHeads = false
input.onGesture(Gesture.Shake, () => {
CoinAHeads = Math.randomBoolean()
CoinBHeads = Math.randomBoolean()
if (CoinAHeads == CoinBHeads) {
basic.showLeds(`
. . # . .
. # . # .
. # # # .
DoubleCoinFlipper
This is an assignment for students to come up with a micro:bit program that uses Boolean variables, Boolean
operators, and possibly the random function.
Input
Remind the students of all the different inputs available to them through the micro:bit.
Project Ideas
Sunscreen Monitor
When you shake the micro:bit, it reports the current temperature in degrees Fahrenheit. Button B measures the
light level and if it is above 70 degrees AND very bright, it will display a sun icon. If it is above 70 degrees and less
bright, it will display a cloudy symbol. If it is dark, it will display a nighttime icon.
Button A displays an animation to tell you whether or not you should use sunscreen (on sunny or cloudy days but
not at night or indoors.)
Make a holder that can hold the micro:bit and a bottle of sunscreen.
This example uses boolean operations because both light level AND temperature must be high in order to trigger
the sun icon:
Board Game: Use boolean variables and random values as part of a board game (or improve your Board Game
from the Variables lesson). Make the board and pieces and a holder for the micro:bit. Try modding a current board
game.
Here is a portion of the board game's code. A boolean variable is used to determine whose turn it is. If player1Turn
is false, then it's player 2's turn. A random number is generated to show the arrow seventy-five percent of the time
(for values of 0, 1, or 2).
Assessment
4 3 2 1
Boolean More than 2 Boolean At least 2 Boolean At least 1 Boolean No Boolean variables
variables are variable is variable is are implemented.
implemented in a implemented in a implemented in a
meaningful way meaningful way meaningful way
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as
pair programming, working in project teams, and participating in group active learning
activities
• 2-A-5-7 Create variables that represent different types of data and manipulate their values.
This lesson presents the concept of binary digits and base-2 notation. Students will learn how data is stored
digitally and how it can be read and accessed.
Lesson Objectives
…
• Understand what a bit and byte are and how they relate to computers and the way information is
processed and stored.
• Learn to count in Base-2 (binary) and translate numbers from Base-10 (decimal) to binary and decimal.
• Apply the above knowledge and skills to create a unique program that uses binary counting as an
integral part of the program.
Introduction
Most everyone who uses a computer has heard the terms, kilobyte (kB), Megabyte (MB), Gigabyte (GB) and
even Terabyte (TB), usually when referring to the size of computer files and hard drives as well as download
speeds. Bandwidth or connection rates are measured in bits/second. But what is a bit and what is a byte and
what do they have to do with computers?
Picture a basic room light. The light is either on or it is off. You control the current state of the light by
flipping a switch that has only two settings, down (light off) and up (light on). The earliest computers used a
series of mechanical switches to control the flow of electricity through their circuits, turning each one on or
off. The on/off states of the circuits was used to represent and even store information. The smallest unit of
information, representing the state of one switch, is known as a bit.
A bit is a binary digit and has only two possible values, zero or one. The value of the bit represents the
current state of a single switch. If the switch is off, then the bit has the value zero. If the switch is on, then the
bit has the value one.
A bit can only represent two different values, zero or one. To represent larger pieces of information, bits are
strung together in sequences of 8 called bytes.
A byte can represent any value from 00000000 through 11111111, for a total of 256 different possible
values. Each digit in a byte can be thought of as representing an individual switch that is either off (zero) or
on (one).
Modern computers rely on transistors, which pack millions of tiny switches into a chip smaller than your
thumb, but information is still represented in essentially the same way: as a series of ones and zeros. By
Review
• A Bit is a binary digit with two possible values, zero or one
• A Byte is a sequence of 8 bits and has 256 possible values from 00000000 through 11111111
• A kilobyte (kB) is 1,024 bytes or 2^10 bytes
• A Megabyte (MB) is 1,048, 576 bytes or 2^20 bytes
• A Gigabyte (GB) is 1,073,741,824 bytes or 2^30 bytes
• A Terabyte (TB) is 1,099,511,627,776 bytes or 2^40 bytes
Notes
• The ones and zeros of bits and bytes can be used to represent letters, numbers, and even different
keys on a computer keyboard.
• B z ‘ ’
‘ ’
In this activity, students will explore the concept of binary numbers by experimenting with a very
odd vending machine that only accepts Base- ’ !I ,
students will become familiar with an alternate numbering system, in this case binary (Base-2).
Students will learn how binary relates to decimal, and will be able to convert between the two
systems.
Materials
• Paper
• Pencil
• ‘ ’ - these could be checkers/chess pieces, cardboard rounds, or even post-it
notes
• Vending machine visual (optional)
Pre-activity preparation
G ‘ ’ , , , 8, ,
Plastic white poker chips work well as coins. You can write the denominations onto one side of
the coins with a whiteboard marker. You can also use small index cards or paper squares. Make
sure to leave one side of each coin blank.
Amount: One set of coins (with one coin of each of the first four denominations in it) for each
student or each pair of students.
Tip
If you have time, create on a poster board, on the whiteboard, or on paper as a handout, a big
rectangle representing a vending machine. Draw in different items for purchase that would
appeal to the students. Have the different items priced differently from 1 unit to 15 units. This is
particularly good to have for younger and more visually oriented students.
You can also just make a very simple vending machine diagram like the one below:
Lead the students to realize that our core monetary denominations, like our number system are
based on ten.
• 1 penny
• 1 dime = 10 pennies
• 1 one dollar bill = 10 dimes (or 100 pennies)
• 1 ten dollar bill = 10 one dollar bills
• 1 hundred dollar bill = 10 ten dollar bills
Our money system is based on our number system, the decimal system. The deci- prefix means
‘ ’
But what is it like to use a different monetary system? A monetary system that has a base other
than ten?
Process
• Give a set of the coins you prepared earlier to each student or pair of students
• Remember to hold onto the 16-unit and 32-unit coins for now
• Present the following scenario:
○ There is a vending machine that sells items of all prices
○ However, the machine cannot give change
○ Therefore, you must pay for everything in exact amounts
○ You have one of each coin: 1, 2, 4, 8.
Questions
• What is the price of the least expensive item you can buy? (1 unit)
• What is the price of the most expensive item you can buy? (15 units)
• What else can you buy? What coin(s) would you use to do this?
• W , ’ ?
Here is where students will start to figure out the different combined sums of different coins.
Y , , “I ’
, ’ ?” N -unit item with 8
+ 2 + 1.
You can now have the students write down how they could pay, what coin(s) could they use to
purchase each of the items priced 1 unit through 15 units with the coins they have OR have a
whole class discussion with you keeping track of their methods of payment on the whiteboard.
Have students line up the coins in their set from greatest to least denomination, left to right.
Questions
• What do you notice about the denominations as they increase from right to left? Each
amount is double (or times 2 or twice) the denomination before it (to its right)
• If we added one more coin to your set of coins that is greater than the 8 unit coin, what is
the next logical coin denomination? 16. Why? Because 16 is ‘2 times’ greater than 8
Hand out the 16 unit coins, one to each student or pair of students.
Questions
• What is the new maximum price you could pay for an item? 31
• What combinations of coins can you use to pay for an item priced from 16 units to this
new maximum price?
Once again, you can now have the students write down how they could pay, what coin(s) could
they use to purchase each of the items priced 16 units through the new maximum price with the
coins they have, OR have a whole class discussion with you keeping track of their methods of
payment on the whiteboard.
Again, there will soon be a general agreement among the students that:
• You can make every amount between 16 units and the new maximum with the 5 coins now
in their set.
• There is only one way to make each of those amounts.
Questions
• If we added one more coin to your set of coins that is greater than the 16 unit coin, what is
the next logical coin denomination? 32. Why? Because 32 is ‘2 times’ greater than 16.
Hand out the 32 unit coins, one to each student or pair of students.
Questions
• What is the new maximum price you could pay for an item? 63
• What combinations of coins can you use to pay for an item priced from 32 units to this
new maximum price?
Once students are comfortable making combinations of numbers, encourage them to use ones
and zeroes to represent the numbers instead. This number system uses the number 2 as its base
(each place is two times the one before it.) It is called the Base-2 system, or binary system. The
number system we are normally familiar with is the Base-10 system, or decimal system (each
place is ten times the one before it.)
With their coins in a line in descending order from right to left on a piece of paper, ask students
For example: Ask them to represent the number 45. See image above.
They should have the 32, 8, 4, and 1 coins face up and the 16 and 2 coins face down.
Ask the students to place a numeral 1 above the coins that are face up and a numeral zero over
the coins that are face down.
The ones and zeros they just drew are the binary number version of the amount represented by
the flipped-up coins. For the example: 45 in Base-10 = 101101 in Base-2
Examples:
0 1 0 1 0 (10)
1 1 0 1 1 0 (54)
Guide the students through building a binary transmogrifier (converter) that converts between
binary (base-2) and decimal (base-10) numbers. Let them figure out a pattern that will allow
them to do the conversion on the fly.
Tell the students that they will be building a binary transmogrifier with the micro:bit.
The user will be able to use the buttons to enter binary 0s and 1s and will be able to press A+B
at any time to display the decimal equivalent of the number that has been entered.
• From the Variables menu, make and name these two variables: decimal, binary.
B ““
variable: a literal string of characters. This is important because you will be adding to this string
character by character.
Transmogrify Me!
We are ready to start entering numbers. Remember that binary numbers are calculated based
“ ” , O
to calculate the decimal value is to wait until the user presses A+B, and then calculate the entire
number based on the value of the string.
H , “ ”,
say, every time the user presses a 1 or a 0, calculate the current decimal value of that string so
you only have to deal with one 0 or 1 at a time.
For example, imagine you are the micro:bit. If the first number the human enters is a 1, you
automatically know the new decimal value is a 1. If the second number that is entered is a 0,
then your decimal value goes from 1 to 2. However, if the second number is also a 1, then your
new decimal value goes from 1 to 3.
, , L ’
decimal value of binary 10 is 2. If the third number entered is a 0, then your new decimal value
goes from 2 to 4. If the third number entered is a 1, then your new decimal value goes from 2 to
5.
If, on the other hand, you have 11 in your binary string, then your decimal value is 3. If the third
number entered is a 0, then your new decimal value goes from 3 to 6. If the third number
entered is a 1, then your new decimal value goes from 3 to 7.
See if you can spot a pattern that will help you figure out, for any given decimal value, what the
new decimal value should be if the user enters a 0, or if the user enters a 1.
H Y ’
Coding Steps
• F I , ‘ ’
coding workspace
• L ' ’ -down menus in the other 2 blocks to
‘B’, ‘ +B’
• Finally, you will need to update the current decimal value with the value of the entire
binary string. This is pretty straightforward if you have been keeping track of the decimal
value every time someone presses a button. The pattern is as follows: (spoiler alert!)
○ Whenever someone enters a 0, the new decimal value is twice the previous value.
○ If someone enters a 1, the new decimal value is twice the previous value, plus 1.
• For Button A, you will need to use the multiplication Math block and your binary variable
block to create the proper formula. You will need to put that formula inside another Math
addition block in order to add one to the result.
Y B B , “ ”
Transmogrifier
Try it out!
Have someone else try your program out. Then think about how the program might be
improved.
Here are some additional modifications you might try:
• Add a way to clear the binary and decimal values so you can start over.
• Add a way to erase the previous value.
• Create a decimal-binary converter that allows you enter a decimal value and see the binary
equivalent when you press A+B.
The unplugged activity uses a vending machine as a model for creating different combinations
of binary place values. We found that for n coins, there is one and only one way to make every
number between 0 and 2^n-1.
For this project, students should invent a paper and cardboard version of the binary counter,
then program it to display the decimal value of those numbers.
Materials
• Cardboard or heavy paper
• Copper tape - https://www.adafruit.com/product/1128,
https://www.sparkfun.com/products/10561
• 3 quarters or other heavy coins
• Scissors
• Duct tape
Tips
This is one possible design for a binary cash register. We used coins and copper tape on a piece
N , “ ” “ ” ,
flipped so it lays flat across both pieces of copper tape, completing the circuit so the micro:bit
can detect that that pin has been activated, and calculates and displays the decimal value of the
binary number that is indicated by the coins.
Copper tape is a thin, flexible strip of copper with an adhesive back. You can sometimes find
copper tape at the hardware, sold as slug tape, to keep slugs out of your garden. Usually,
Because the micro:bit only has three pins, this binary register is limited to three place values.
Students might use variables to represent each of the three place values, or they can simply
keep a running total by adding the appropriate amount when each of the three pins is pressed.
You can stick the micro:bit into place using some sticky tape, or you can create an actual holder.
The copper tape connections are delicate though, so be careful when plugging and unplugging
the power cable from the board.
Extra Mods
• Write some code that will display the number in binary when you press the A button.
• Think of a way to create more place values, perhaps by using a second micro:bit and a
Radio connection.
• What were the Variables that you used to keep track of information?
• What mathematical operations did you perform on your variables?
• What information did you provide?
• Describe what the physical component of your micro:bit project was (e.g., an armband, a
wallet, a holder, etc.)
• How well did your prototype work? What were you happy with? What would you change?
• What was something that was surprising to you about the process of creating this project?
• Describe a difficult point in the process of designing this project, and explain how you
resolved it.
Assessment
4 3 2 1
Binary All binary numerals At least 2 binary At least 1 binary No binary numerals
display display correctly numerals display numeral displays display correctly.
correctly
Micro:bit program: Micro:bit Micro:bit Micro:bit program
• Uses binary in a way program lacks 1 program lacks 2 lacks 3 or more of
that is integral to the of the required of the required the required
Micro:bit program elements elements elements
program • Uses mathematical
operations to add,
subtract multiply,
and/or divide variables
• Compiles and runs as
intended
• Meaningful comments
in code
Reflection Reflection piece Reflection piece Reflection piece Reflection piece
includes: lacks 1 of the lacks 2 of the lacks 3 of the
Resources
• https://www.mathsisfun.com/binary-number-system.html
This lesson covers the use of more than one micro:bit to share and combine data. Students will explore a
complex epidemiological program (Infection) that demonstrates the Radio functionality of the micro:bit.
Students will send and receive numbers and strings in a series of guided activities. Finally, students are
asked to collaborate so that they can share their micro:bits and create a project together.
Lesson Objectives:
…
• Understand how to use the Radio blocks to send and receive data between micro:bits
• Understand the specific types of data that can be sent over the Radio
Introduction
Up to this point, we have been primarily challenging students to collaborate while they create their own
projects. This lesson, on communication using the micro:bit radio, is a great opportunity to have students
work in pairs on a project. Have kids find a partner to work with for this lesson, and make sure they are
seated next to each other.
N “ ”
collaborate when programming. Two students share one computer, with one student at the keyboard
acting as the driver, and the other student providing directions as the navigator. Students must practice
good communication with each other throughout the entire programming process.
The micro:bit allows you to communicate with other micro:bits in the area using the blocks in the Radio
category. You can send a number, a string (a word or series of characters) or a string/number combination
in a radio packet. You can also give a micro:bit instructions on what to do when it receives a radio packet.
“ ” ,
The project for this lesson will challenge students to work together to send and receive some sort of data
to and from each other. There is a wide range of simple and complex projects kids can try, but whatever
they choose it is a whole lot of fun to communicate with each other using the micro:bits!
For this activity, each student will need a micro:bit and battery pack, as well as the teacher who will be the
Master controller.
Setup
This site is the home page for the Infection game:
https://pxt.microbit.org/projects/infection
On that page you should be able to copy the JavaScript code, then go to your MakeCode JavaScript editor and
paste the JavaScript code into the window.
Then click the Download button to download this program onto your micro:bit. This code should be
’
I ’ , !
game, the teacher should press the A + B buttons on his or her device. This will register all of the student
’
Explore
In this phase, students should just play the game to get a feel for how it works. The object of the game is to
meet as many people as possible without getting sick. If at any time players decide to stop meeting people,
they should sit down and cover their micro:bit.
To start the game, students should take their devices and spread out. When everyone is ready to begin, the
teacher should press the A + B buttons again. All of the student devices will show a unique player icon.
One of the players is randomly chosen to have a virus that is transmitted when they meet other players. Players
can meet each other by going up to another player and placing the two devices next to each other. Players who
are healthy, or who are infected but are not showing symptoms yet, will have a smile. Once a player is sick, their
micro:bit will display a frowny face.
After a certain period of time being sick, the player dies and the micro:bit will display a skull icon. That player
should sit down and wait for the game to end, when all players are dead or the virus stops spreading.
Discuss
After one round, it is good to have a discussion with the players:
• Did anyone manage to stay healthy? If so, how? If not, why not?
• How do you think the disease spread?
• Who do you think started it?
• What could we do to find out?
• What strategies might we adopt next time, to have a better outcome?
Test
Play the game one more time, or more depending on available time, and attempt to test some of the theories
students came up with.
• What strategies worked well?
• Which strategies seemed like a good idea at the time, but in practice, were less effective? Why?
• Are there any real-world situations that this might remind you of?
Vocabulary
As students talk through their theories, they will often talk about a scientific idea without knowing the specific
word for it. This presents a nice opportunity, once students have surfaced an idea, to give it a proper name so
that you can start to develop a common working vocabulary for talking about the problem.
Reference
This game is a distributed simulation of a viral outbreak. It is modeled after the Thinking Tags participatory
simulations developed at MIT Media Lab. Participatory Simulations have been found to enhance student
understanding of complex dynamic relationships, inquiry skills, and scientific understanding. (Colella, V. (2000).
Participatory Simulations: Building Collaborative Understanding Through Immersive Dynamic Modeling. Journal
of the Learning Sciences, 9(4), 471–500. http://doi.org/10.1207/S15327809JLS0904_40\)
Guide the students in creating programs that use the radio communication blocks to send and receive data
between two micro:bits.
Notes:
• When using the radio blocks, the micro:bit simulator will show two micro:bits
• In the simulator, a radio transmission icon will appear in the top right corner of the micro:bit. The icon will
light up as the micro:bit is transmitting data.
• In the simulator, all the code in the coding workspace runs on both virtual micro:bits. You should include for
how to send data as well as what to do when it receives data.
Marco Polo
Send and receive strings between micro:bits.
On button A pressed, we will send the string Marco and on button B pressed we will send the string Polo.
• When communicating between micro:bits, it is important that the micro:bits involved are all using the same
group ID. So, the first thing we will do is set the group ID number.
• From the Radio menu, drag a 'radio set group' block to the coding workspace and place the block into the on
start block.
• In the 'radio set group block', leave the default value of 1 for the group ID
radio.setGroup(1)
input.onButtonPressed(Button.A, () => {
radio.sendString("Marco")
})
input.onButtonPressed(Button.B, () => {
radio.sendString("Polo")
})
To display the data sent between the micro:bits, drag an 'on radio received receivedString' block to the
input.onButtonPressed(Button.A, () => {
radio.sendString("Marco")
})
radio.onDataPacketReceived(({ receivedString }) => {
basic.showString(receivedString)
})
input.onButtonPressed(Button.B, () => {
radio.sendString("Polo")
})
radio.setGroup(1)
MarcoPolo
input.onButtonPressed(Button.A, () => {
radio.sendString("Marco")
music.playTone(131, music.beat(BeatFraction.Whole))
})
radio.onDataPacketReceived( ({ receivedString }) => {
basic.showString(receivedString)
})
input.onButtonPressed(Button.B, () => {
radio.sendString("Polo")
music.playTone(262, music.beat(BeatFraction.Whole))
})
radio.setGroup(1)
basic.showLeds(`
# . # # #
MarcoPoloMods
Morse Code
Send and receive numbers between micro:bits.
Depending on the button pressed, send a different number value between micro:bits. On receiving a number,
display a different image unique to the number sent. One number will represent a dot, another a dash and another
a space or stop.
radio.setGroup(1)
basic.showString("Morse Code")
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
input.onButtonPressed(Button.B, () => {
radio.sendNumber(1)
})
input.onButtonPressed(Button.AB, () => {
radio.sendNumber(2)
• From the Radio Toolbox drawer, drag an 'on radio received receivedNumber' event handler to the coding
workspace.
• Since we will display a different image depending on the number value received, we need a logic block.
• From the Logic Toolbox drawer, drag an 'if...then' block to the coding workspace and place it in the 'on radio
received receivedNumber' event handler.
In order to know whether to display a dot, a dash, or a space/stop image, we need to compare the number
received to the values 0, 1, and 2.
• From the Logic Toolbox drawer, drag a 0=0 comparison block into the coding workspace.
• Replace the default value 'true' of the 'if...then' block with the comparison block.
• From the Variables Toolbox drawer, drag a 'receivedNumber' variable block into the coding workspace, and
drop it into the first slot of the comparison block
• Leave the righthand side default value of zero in the 0=0 block.
}
})
• Place a 'show leds' block in the space after the then of the 'if...then' block.
• Create an image to represent a dot.
Try it!
• Download your program to the micro:bit
• Press button A on the sending micro:bit
• Does this cause a dot to be displayed on the receiving micro:bit?
• However, pressing button A again does not appear to send another dot as the image on the receiving
micro:bit does not appear to change.
• Change the values on the righthand side of the comparison block to 1, and 2.
• Modify the images displayed to show a dash, and a full screen of lights
MorseCode
Now our program runs as we designed it to run and is more efficient, too!
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
})
input.onButtonPressed(Button.B, () => {
MorseCodeFinal
For this project, students should work in pairs to design a project that incorporates radio communication to send
and receive data in some way. Some projects may have two separate programs: One that receives data, and one that
sends data. Students might each choose to submit one program in that case.
In other cases, a pair of students might submit one program that has both sending and receiving code in it, and the
same code is uploaded to two or more micro:bits.
Project Ideas
Stop, Thief!
Design an alarm system for your bedroom that alerts you with a screen animation when someone opens your door.
You can mount one micro:bit on your door and use the accelerometer to send a signal over the radio when it is
being moved.
Interactive Art
Create a piece of interactive artwork that receives something as input over the radio from another micro:bit, and
displays something based on that as output.
3-Note Keyboard
This is a simple three-note keyboard that uses wooden paint stirrers and copper tape to make a connection to each
of the three pins on the micro:bit.
When a key is pressed, it sends a number over the radio to a second micro:bit that plays the appropriate tone over a
set of earbuds. This allows you to use each of the three pins on the first micro:bit to play a different tone.
let sound = 0
radio.onDataPacketReceived( ({ receivedNumber }) => {
if (receivedNumber == 0) {
sound = 349
music.playTone(sound, music.beat(BeatFraction.Half))
3NoteKeyboard
Reflection
Have students write a reflection of about 150–300 words, addressing the following points:
• What kind of Project did you do? How did you decide what to pick?
• How does your project use radio communication?
Assessment
4 3 2 1
Radio Effectively uses the Radio to Effectively uses the Radio Use of Radio is No working
send and receive data, with to send or receive data, incomplete or non- and/or
meaningful actions and with meaningful actions functional and/or meaningful use
responses for each. and responses for each. tangential to operation of Radio.
of program
Micro:bit Micro:bit program: Micro:bit program lacks 1 Micro:bit program lacks Micro:bit
program • Uses Radio blocks in a way of the required elements 2 of the required program lacks
that is integral to the elements all of the
program required
• Compiles and runs as elements
intended
• Meaningful comments in
code
Collaboration Reflection piece includes: Reflection piece lacks 1 of Reflection piece lacks 2 Reflection piece
reflection • Brainstorming ideas the required elements. of the required lacks 3 of the
• Construction elements. required
• Programming elements.
• Beta testing
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as
pair programming, working in project teams, and participating in group active learning
activities.
This lesson covers storing and retrieving data in an ordered fashion using Arrays. Introduces JavaScript as an
alternate way of creating and modifying code. Uses a melody as a list/array of notes.
Lesson Objectives
…
• Explain the steps they would take to sort a series of numbers
• Recognize three common sorting algorithms
• Learn
• Apply
Introduction
Any collector of coins, fossils, or baseball cards knows that at some point you need to have a way to organize
everything so you can find things. For example, a rock collector might have a tray of specimens numbered like this:
Every rock in the collection needs its own storage space, and a unique address so you can find it later.
As your MakeCode programs get more and more complicated, and require more variables to keep track of things,
you will want to find a way to store and organize all of your data. MakeCode provides a special category for just
this purpose, called an Array.
• Arrays can store numbers, strings (words), or sprites. They can also store musical notes.
• Every spot in an array can be identified by its index, which is a number that corresponds to its location in the
array. The first slot in an array is index 0, just like our rock collection above.
In MakeCode, you can create an array by assigning it to a variable. The Array blocks can be found under the
Advanced Toolbox menu.
list = []
list = [4, 2, 5, 1, 3]
The code above creates an empty array called list, then fills it with five numbers, indexed from 0 to 4. The index of
the first value (4) is 0. The index of the second value (2) is 1. The index of the last value (3) is 4.
You can get items out of the array by specifying its index like this:
input.onButtonPressed(Button.A, () => {
basic.showNumber(list[0])
})
The code above takes the first element in the array (the value at index 0) and shows it on the screen.
There are lots of other blocks in the Arrays Toolbox drawer. The next few Activities will introduce you to them.
Discussion
• Ask your students if any of them collects anything. What is it? Comic books, cards, coins, stamps, books, etc.
How big is the collection?
I , ’
collections.
• Length: the total number of items in the collection
• Sort: Items in the collection are ordered by a particular attribute (e.g., date, price, name)
• Index: A unique address or location in the collection
• Type: The type of item being stored in the collection
References
Once you start saving lots of different values in an array, you will probably want to have some way to sort those
values. Many languages already implement a sorting algorithm that students can call upon as needed. However,
understanding how those different sorting algorithms work is an important part of computer science, and as
students go on to further study they will learn other algorithms, as well as their relative efficiency.
In this activity, you will demonstrate different kinds of sorting methods on your own students. This is an
unplugged activity, so your students will be standing at the front of the room. If you or your students are curious
to see what these different sorts look like in code, we have included a MakeCode version of each algorithm in
this lesson, for you to explore if you choose.
Materials
• Sheets of paper numbered 1–10, one large printed number to a page
Set Up
• Have up to ten students (the Sortees) stand up at the front of the classroom. Ask another student to
volunteer to be the Sorter.
• Mix up the order of the papers and give each student a piece of paper with a number on it. They should
hold the paper facing outward so their number is visible. Each of these students is like an element in an
array.
Initial Sort
• Ask the Sorter to place the students in order by directing them to move, one at a time, to the proper place.
• Once the students are sorted, ask students the following:
○ How did she sort you into the right order?
○ Did you see a pattern?
○ What did she do?
Try to get students to be as precise as possible in explaining their thinking. Sometimes it helps to put the steps
on the board, in an algorithm:
• First, she went to the first student, then put him in the right place.
• Then she went to each of the next students and put them in the right place.
Ask for clarification when necessary: What does it mean when you say “put them in the right place”?
Bubble Sort
Compare the first two students. If the student on the right is smaller than the student on the left, they should
swap places. Then compare the second and third students. If the student on the right is smaller than the student
on the left, they should swap places. When you reach the end, start over at the beginning again. Continue in this
way until you make it through the entire row of students without swapping anybody.
In Pseudocode
1. Create a variable called counter.
2. Set the counter to zero.
3. Go through the entire array.
In MakeCode
Note: Press B to display the array visually. The length of each vertical bar represents each number in the array,
from left to right. Press A to sort the array using Bubble Sort. Press A + B to generate new random numbers for
the array.
let temp = 0
let row = 0
let list: number[] = []
let counter = 0
let column = 0
let index = 0
input.onButtonPressed(Button.AB, () => {
for (let index = 0; index <= 4; index++) {
list[index] = Math.random(5) + 1
}
})
input.onButtonPressed(Button.B, () => {
basic.clearScreen()
for (let column = 0; column <= 4; column++) {
row = 0
while (row < list[column]) {
led.plot(column, 4 - row)
row += 1
}
}
})
BubbleSort
In Pseudocode
1. Find the smallest unsorted value in the array.
2. Swap that value with the first unsorted value in the array.
3. Repeat steps 1 and 2 while the number of unsorted items is greater than zero.
In MakeCode
Note: The inner loop gets smaller as the sorting algorithm runs because the number of unsorted items decreases
as you go. The index that the inner loop starts at needs to change as the number of sorted items increases, which
is why we have to use a separate counter (item) and compute j every time through the inner loop.
SelectionSort
Insertion Sort
Take the first student on the left and consider that person sorted. Next, take the next student and compare him
to the first student in the sorted section. If he is greater than the first student, then place him to the right of the
student in the sorted section. Otherwise, place him to the left of the student in the sorted section. Continue
down the line, considering each student in turn and then moving from left to right along the students in the
In Pseudocode:
1. For each element in the unsorted section of the list, compare it against each element in the sorted section
of the list until you find its proper place.
2. Shift the other elements in the sorted list to the right to make room.
3. Insert the element into its proper place in the sorted list.
In MakeCode
let j = 0
let row = 0
let element = 0
let list: number[] = []
input.onButtonPressed(Button.A, () => {
for (let i = 0; i <= 4; i++) {
element = list[i]
j = i
while (j > 0 && list[j - 1] > element) {
list[j] = list[j - 1]
j += -1
list[j] = element
}
basic.clearScreen()
for (let column2 = 0; column2 <= 4; column2++) {
row = 0
while (row < list[column2]) {
led.plot(column2, 4 - row)
row += 1
}
basic.pause(100)
}
}
InsertionSort
Sidebar
I 8, I B O G ’ O ,
https://www.youtube.com/watch?v=k4RRi_ntQc8
N W ’
• Click on the blue gear-wheel icon in the top left corner of the 'create array' block.
• From the pop up window, add as many values (elements) as you'd like to the array block
by dragging the value block from the left side of the window to the array block on the
right side of the window.
• F , ’
• Fill each string with one word. Choose words that will be fun for a game of charades.
Example:
Now, we need a way to access one word at a time from this array of words.
We can use the 'show string' block from the Basic Toolbox drawer, and the 'on screen up'
• To start the game with the index at zero, add a 'set' variable block to the 'on' start block.
• Next, add the following:
○ an image as a placeholder for when the program has started. Since charades is a
guessing game, we made one that looks like a question mark (?),
○ a countdown to the first word using show number blocks and pause blocks
○ And show the first word in the array
Once that word has been guessed (or passed), we need a way to advance to the next word in
the array.
• We can do this by changing the index of the array with the 'on screen down' event handler
from the Input Toolbox drawer (this is a drop-down menu choice of the 'on shake' block)
to advance to the next word when we tilt the micro:bit down
input.onGesture(Gesture.ScreenDown, () => {
index += 1
})
We have a limited number of elements in our array, so to avoid an error, we need to check and
make sure we are not already at the end of the array before we change the index.
• Under the Arrays Toolbox drawer, drag out a 'length of' block. The 'length of' block returns
the number of items (elements) in an array. For our array, the length of block will return
the value 6.
• But because computer programmers start counting at zero, the index of the final (6th)
element is 5.
*Notes:
• Our array has a length 6, so this will mean that as long as the current value of the index is
less than 5, we will change the array by one.
• ‘ ’
array makes this code more flexible and easier to maintain. We can easily add more
elements to our array and not have to worry about changing numbers elsewhere in the
code.
We can put this all together with an 'if...then...else' block and a 'less than' comparison block from
the Logic Toolbox drawer, a subtraction block from the Math Toolbox drawer, and a 'game over'
block from the Game Toolbox drawer (located under the Advanced menu).
, ’
• In case a word is already scrolling on the screen when a player places the micro:bit screen
down, we can stop this animation and clear the screen for the next word by using a 'stop
animation' block from the Led More Toolbox drawer, and a 'clear screen' block from the
Basic More Toolbox drawer.
input.onGesture(Gesture.ScreenDown, () => {
led.stopAnimation()
basic.clearScreen()
if (index < arrayWords.length - 1) {
index += 1
} else {
game.gameOver()
}
})
Game Play
There are different ways you can play charades with our program. Here is one way you can play
with a group of friends.
• With the micro:bit on and held so Player A cannot see the screen, another player starts the
program to see the first word.
• The other players act out this word charades-style for Player A to guess.
• When Player A guesses correctly or decides to pass on this word, a player places the
micro:bit screen down.
• When ready for the next word, a player turns the micro:bit screen up. Play continues until
all the words in the array have been used.
Mod this!
• Add a headband to hold the micro:bit on the Players' foreheads (using cardboard, paper,
rubber bands, etc.)
• Add a way to keep score
• Keep track of the number of correct guesses and passes
• Add a time limit
let index = 0
let arrayWords: string[] = []
Charades
This is a project in which students are challenged to create a musical instrument that uses arrays
to store sequences of notes. The array of notes can be played when an input occurs, such as one
of the buttons being pressed, or if one or more of the pins is activated.
Ideally, the micro:bit should be mounted in some kind of housing, perhaps a guitar shape or a
music box. Start by looking at different kinds of musical instruments to get a sense of what kind
of shape you might want to build around your micro:bit.
Here are some examples of guitars that were made out of cardboard and colored, patterned
duct tape that you can buy in craft stores.
Song-Maker
SongMaker
Here is an example of how to create an array with musical notes. Button A plays every note in
the array. Button B plays the notes at twice the frequency (but doesn't alter the original notes.)
Remember that a 'for element value of list' loop makes a temporary copy of the value, so even if
you change a value, it will not change the original element in the array. If students want to
permanently change the values in their array (transpose music to increasingly higher keys, for
example) they can use a for loop like this:
MusicArray
Assessment:
4 3 2 1
Array Stores and Stores each Array skips values Array doesn't work at
iterates element of the or has other all or no array
through each array successfully problems with present
element of the storing and/or
array retrieving
successfully elements
Micro:bit • Uses at least Uses an array in a Array is poorly Micro:bit program
program one array in a tangential way that implemented lacks 3 or more of
fully is peripheral to and/or peripheral the required
integrated function of project to function of elements
and and/or program project, and/or
meaningful lacks 1 of the lacks 2 of the
way required elements required elements
• Compiles and
runs as
intended
• Meaningful
comments in
code
Collaboration Reflection Reflection piece Reflection piece Reflection piece
reflection piece lacks 1 of the lacks 2 of the lacks 3 of the
includes: required elements. required required elements.
• Brainstormin elements.
g ideas
• Construction
• Programming
• Beta testing
• 2-A-2-1 Solicit and integrate peer feedback as appropriate to develop or refine a program
• 2-A-6-10 Use an iterative design process (e.g., define the problem, generate ideas, build,
test, and improve solutions) to solve problems, both independently and collaboratively.
• CT.L3B-06 Compare and contrast simple data structures and their uses (e.g., arrays and lists).
In this unit, we will be reviewing the concepts we covered in the previous weeks, and providing
some ideas for an independent final project that students can focus on in the next several
weeks. We will also provide a rubric for keeping students on task and tracking the learning that
they are doing as they work on their projects. This is an expanded version of the process
students followed in the Mini-Project, in Lesson 6.
Students are asked to create an independent project that demonstrates the use of something
they have already learned, something they went out and researched for themselves, something
they borrowed from somewhere else (with citations) and something completely original. They
are also asked to document their learning process throughout the next couple of weeks using
an independent project framework that emphasizes metacognitive development and process-
oriented work.
Booleans
A Boolean is a data type that only has two possible values: True or False. You can use boolean variables to keep
track of the state of a game (gameOver is either true or false) or check to see whether a certain action has taken
place yet (messageSent is either true or false). Boolean operators such as AND OR and NOT allow you to
combine boolean expressions to make more complex conditions.
Radio Communication
Micro:bits can send a combination of strings and numbers using the Radio blocks. The Infection activity is an
example of a thought-provoking group simulation that uses the Radio to send and receive data between
micro:bits.
Arrays
Arrays in MakeCode are used to store and retrieve numbers, strings, musical notes, or sprites. Everything in a
particular array needs to be the same data type and elements in an array are numbered starting from zero, also
called the index. Objects can be accessed, changed, added to, or removed from an array using their index. Three
common methods of sorting elements in an array are bubble sort, selection sort, and insertion sort.
The final project is a chance for you to use all of the skills you have been learning throughout the semester to create something
that is original, and that solves a problem or serves a purpose.
Possible ideas
• Create a game
• Create something that helps somebody by solving a problem
• Create something beautiful
• Create a musical instrument
Timeframe
Three weeks of in-class work and activities
Assessment:
• 50% Process (initial proposal, work logs, records of thinking, final narrative)
• 50% Product (project code and maker component)
Teacher Note: This form of assessment places just as much weight on documenting the process of designing the project, as it
does on the finished product itself. This is because in my classroom I want to prioritize "sustained effort over an extended period
of time" over a project that might have resulted from three all-nighters in the final week it is due.
However, you may decide to assign more or less weight to each of these pieces, and you should certainly feel free to scale up or
down the documentation piece as appropriate for your classroom, grade level, and teaching priorities.
Work Logs
Teacher Note: We generally don't accept late work logs. If a student simply didn't have time to do any work on the project, he
should still file a work log, and report that no work got done. Work logs are worth a few points each, so missing one or two isn't
a problem, but if it happens a lot it's usually time to do a check-in with that student and see where she is with the project.
Record of Thinking
A Record of Thinking is like a journal entry (or like the reflection that you did for the mini-project) that tells the story of your
learning throughout the past week. Go through your work logs for the week and look at what you did, where you got stuck, and
how you figured it out.
Teacher Note: A Record of Thinking is not an expanded work log! Students will sometimes just write a more detailed list of all of
the tasks they completed over the week, and that's not the point of the Record of Thinking. The Work Logs are to show WHAT
you did. The Record of Thinking is to show HOW you learned how to do it. Unlike Work Logs, I will accept late Records of
’ R I
documentation of the learning process.
You acknowledge that you have consented to sharing your code by clicking Publish project.
You also need to create a written final narrative to accompany your code.
You have worked for the past three weeks to propose, design, and test an original micro:bit independent project. I am looking
for an honest, accurate assessment of your work over this time.
Please go back and read through all of your Work Logs, Records of Thinking, Beta Testing feedback, and any notes from teacher
conferences.
Then, compose a comprehensive narrative that tells the story of the development of this app, and your progress toward your
goals along the way. How you tell the story is up to you, but you might consider following most, if not all, of the following
questions:
• How did you start the process of designing the product/meeting your goals?
• What did you hope to learn?
• What challenges did you face? How did you overcome them?
• What was the outcome?
• What did you learn in the end?
• Who in the class provided help to you along the way? How?
• What were you proud of?
• What would you do differently next time?
Throughout your narrative, you must cite evidence from your work logs and records of thinking (e.g., Record of Thinking 4/17,
Work Log #3, Conference notes, etc.) You may use footnotes for this or add it in parentheses after the material you are citing.
I will read this carefully and grade it along with your final project code and average it with the total of your work logs and
records of thinking to come up with your final grade for the project.
Once I started to get a little more clear on what to do, I was able to get more effective help from my classmates. Specifically,
Jordan helped me a lot with figuring out how to get an image to display properly on the screen. He also showed me how to
search through the online documentation more effectively. I think if I could do this over again, I would have scheduled more
time earlier to meet with Mr. Kiang and/or found a better way to share the different online sites with my table mates because
we all found different places to go. I didn’t even find out until the end that you could jump into JavaScript to make changes to
the code, and it makes it all with the right blocks when you go back! (Beta Testing notes) That would have saved me a lot of
time.
Beta Testing
Beta testing is an important part of testing the final projects to uncover bugs or design issues that could make the projects
difficult to use. One way to test the projects is to ask all students to come in to class on a specific day with the projects ready to
test. This is not the final deadline, but projects should be "feature-complete" i.e., all features need to be incorporated into the
micro:bit, and the construction of the real world elements of the project need to be done or almost done.
Students can take turns presenting their projects to the entire class, or they can work in pairs to take turns trying their partner's
project out and offering feedback. Students who are being critiqued should take beta testing feedback notes and turn them in as
part of their final project narrative.
Final Showcase
Have a celebration of your students' hard work and hold an event at your school for parents, administrators, and other
community members to appreciate all of the hard work that went into making each of the final projects.
We have found that a "science fair" format works nicely, with students sitting at tables where they can demonstrate their projects
and answer questions. Some schools do a "shark tank" type of event where students take turns "pitching" their project ideas to a
panel composed of local software developers, entrepreneurs, and investors. Either way, a little public recognition of all of your
students' hard work goes a long way!
Assessment
4 3 2 1
Code - Code very effectively Code effectively Code somewhat effectively Code demonstrates the use
Show what demonstrates the use of demonstrates the use of demonstrates the use of of previous concept(s), yet
you know previous concept(s). All previous concept(s). Most previous concept(s). Only is not effective. Few or no
variable names are unique variable names are unique some variable names are variable names are unique
and clearly describe what and/or clearly describe unique and/or clearly and/or clearly describe
information values the what information values describe what information what information values
variables hold. Code is the variables hold. Code is values the variables hold. the variables hold. Code is
highly efficient. mostly efficient. Code is somewhat efficient. not efficient.
Code very effectively Code effectively Code somewhat effectively Code demonstrates the use
demonstrates the use of demonstrates the use of demonstrates the use of of new concept(s), yet is
Code - new concept(s). All new concept(s). new concept(s). Only some not effective. Few or no
Show variable names are unique Most variable names are variable names are unique variable names are unique
something and clearly describe what unique and/or clearly and/or clearly describe what and/or clearly describe
new information values the describe what information information values the what information values
variables hold. Code is values the variables hold. variables hold. Code is the variables hold. Code is
highly efficient. Code is mostly efficient. somewhat efficient. not efficient.
Tangible component is Tangible component is Tangible component does No tangible component
tightly integrated with the somewhat integrated with not add to the functionality
Maker micro:bit and each relies the micro:bit but is not of the program.
component heavily on the other to essential.
This project straps to a pitcher's arm and uses the micro:bit accelerometer to record how many pitches
have been thrown in a session.
This project features a secret combination that opens the top of the box using a servo motor
4. Violin Tuner
This project uses a piece of cardboard to mount the micro:bit to the side of a violin. This student wanted to
use it to tune his violin by playing a specific series of tones. The micro:bit displays the note being played.
This example was used for Marching Band practice, where students must hold the trumpet at a 15 -degree
angle to avoid hitting the person in front of them or playing directly into their ears. Because the trumpet is
heavy, new trumpet players tend to let the trumpet droop. This displays an icon (a check mark or an X) to
help new trumpet players learn what the proper angle is supposed to feel like.
• CL.L2-03 Collaborate with peers, experts, and others using collaborative practices such as pair
programming, working in project teams, and participating in group active learning activities.
• CL.L2-04 Exhibit dispositions necessary for collaboration: providing useful feedback, integrating feedback,
understanding and accepting multiple perspectives, socialization.
• CL.L2-05 Implement problem solutions using a programming language, including: looping behavior,
conditional statements, logic, expressions, variables, and functions.