Blocks from the Basic Category¶
The category includes the blocks used for running (starting) programs, as well as blocks for displaying numbers, text or images.
It’s time to create a program, which will display the message “Hello!”.
To display the greeting message (on the simulator or on the Micro:bit display), we have to drag the block from the category to the work surface and insert it into the block . We can type in the desired message “Hello!” by clicking on the text input field.
The final look of the program, which displays the greeting message “Hello!”:
We have two options to test the program:
to run it in the simulator by clicking the button.
to download it to the Micro:bit device. In order to transfer the program to the Micro:bit device, we need to connect it to the computer by using the USB cable. You download the .hex file to your computer by clicking the button.
We will use the simulator to test the program. The running of the program is triggered by clicking on the button, i.e. the greeting message “Hello!” is displayed.
Task. Create a program which will display the message “Hello!” an infinite number of times. Little help: The block is the block which will repeat the commands inserted in it an infinite number of times. The running of this block will never stop on its own. To stop the running of this block, you need to press the stop button.
You can compare your solution with ours: https://makecode.microbit.org/_9Cw5d6Czda1d
In the category ).
Task. You want to create a program that displays a smiley face on the screen.
You can compare your solution with ours: https://makecode.microbit.org/_CAdaFfKsY46a
- Block on start.
- The answer is not correct. The onstart block is one of the blocks from the category Basic, and blocks within it are executed only once during the running of the program.
- Block forever.
- Bravo! The forever block is the block within which commands will be executed an infinite number of times. The running of this block will never stop on its own. To stop the running of this block, you need to press the stop button (|stop|).
Q-1: Which block, used for starting a program, will you have to use if you want the images of an empty square and a full square to alternate on the screen?
Apart from the blocks mentioned above, in the category , you can also find the blocks for displaying number values , blocks used to slow down the running of the program , the time interval code is presented in milliseconds 1000ms is 1 second, as well as the block for clearing the screen .
Task. Using the example from the question above, about the alternating images of squares, try to slow down the time it takes for the image to change, by two seconds. Little help: Use the block.
Check our solution: https://makecode.microbit.org/_F5h5UKD2Vgau
Additional task. You need to turn on 3/5 LEDs on the Micro:bit. The display of illuminated LEDs has to be unique!
You can compare your solution with one of the possible solutions: https://makecode.microbit.org/_29YWXrLHg22U