Review
Here is a brief review of the topics we covered in lessons 7–12.
Coordinate Grid and LEDs
The micro:bit’s 25 LEDs are arranged in a 5x5 grid, with the origin at the top left. Values for both the x and y axes start at zero and increase as you move down and to the right. Individual LEDs can be turned off and on by specifying a pair of coordinates. The current value of an LED can be checked, and its brightness can be changed, as well.
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.
Bits, bytes, and binary
Computers work with base-2, which uses binary numbers. Binary numbers only have two possible values: 0 or 1.
Radio communication
A 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.