Wake up micro:bit

Using the commands:
– forever,
– if then else,
– comparison >,
– sound level,
– show icon,

create a program where the micro:bit displays a sleeping face with its LED lights until its microphone detects a sound level greater than 100. If the sound level is greater than 100, the smiley face will wake up. Checking the sound level will be done using the if then else command. This command is used to check logical conditions and execute parts of the program depending on the result of the check. If the logical condition is met, the code in the then part will be executed, and if not, the code in the else part will be executed.

Instructions for creating the program


Inside the forever loop, place the if then else command, which you can find in the Logic category. Within the if part of the command, you’ll find the word true, where you need to place the condition. You’re checking if the sound level is greater than 100, so you’ll use the comparison > command from the Logic category in the if part. Place the sound level command in the left field of the comparison command, and write the number 100 in the right field.


If the condition is met (sound level is greater than 100), the smiley face must be displayed; otherwise, the sleeping face is displayed. Therefore, place the show icon command in the then part and choose the smiley face by clicking on the dropdown menu. Also, place the show icon command in the else part, but here choose the sleeping face icon.

JavaScript code

Although your programs are created using Blocks, you’ll need to copy the JavaScript code of your created program for solving certain escape room tasks. After you create a program in MakeCode Blocks editor, you can see its JavaScript version by going to JavaScript mode.

Copy the JavaScript code from your Wake up micro:bit program and paste it into the box below:

This publication reflects the views only of the author, and the Commission cannot be held responsible for any use which may be made of the information contained therein.