Why
To build a robot with legos, you will need to understand how to use variables in your program that controls the robot.
What
In this lesson you will learn about variables and how use them in a program for the microbit.
How
You will create a program in Microsoft Makecode that utilizes variables and builds on the skills you learned about button pressing events.
What you will need for this activity:
1. A laptop, desktop, or chromebook
2. An internet connection
3. A Microbit v2
4. USB cable to connect microbit to
computer
The Lesson
1. Open https://www.microsoft.com/en-us/makecode in a web
browser
2. Sign in with your free account by clicking the Sign in in the
top right of the screen
3. After signing in, click on the picture of the micro:bit, this
should take you to https://makecode.microbit.org/
4. Click on the purple New Project rectangle image to create a
new project
5. Enter “variables” for the name of your project, then
click the green Create button.
Variables are used in almost every program in almost every
programming language. If this is your first time hearing about
variables, I want you to think of them as boxes that you can put
different things in. If you want to store a number or some text in a
variable, think of having a piece of paper with the value written on
it. You can put that single piece of paper in the box. If you need to
change the value in the variable, you would take the piece or paper
out and replace it with another piece of paper. Variables are useful
for keep track of things. like a score in a video game.
Challenge
Challenge and solution guide for this lesson is currently only available to subscribers.
Review
In this lesson you learned how use variables in your program.
Next lesson
In the next lesson you will learn about conditionals and how to use them in your microbit programs.