Unit 2.2: MakeCode: Remembering Stuff with Variables

If you haven’t already completed Unit 2.1, we recommend you do that part before starting Unit 2.2.

Computers like the Cliq Robot’s brain have memory to store and read and update information.
Memory is where a program stores any kind of information about itself, what it’s doing, or what’s happening out in the world.

00110001 00110010 00110011 00110100 00110101 00111111 00100000 01010111 01101000 01100001 01110100 00100000 01101011 01101001 01101110 01100100 00100000 01101111 01100110 00100000 01101001 01100100 01101001 01101111 01110100 00100000 01110101 01110011 01100101 01110011 00100000 00110001 00110010 00110011 00110100 00110101 00100000 01100110 01101111 01110010 00100000 01110100 01101000 01100101 01101001 01110010 00100000 01100011 01101111 01101101 01100010 01101001 01101110 01100001 01110100 01101001 01101111 01101110 00100001 00111111
The combination is in here somewhere…

We give each piece of information a name to know which piece of information we’re reading from or changing.
These are called Variables; because we might change (vary) the information stored there later on.

Q: Wait! Didn’t you say there were only four block types?
A: Yes – a Variable is a special type of Expression, and can be used in all the same places you use a number or maths equation.

In this unit, we’ll write some programs that need to use variables.