7. case 04:Timer¶
7.5. Programming¶
Step 1¶
- When start our program, create a variable
flagand set its value to 0. When button A is pressed, delay time for 5 second. When button B is pressed, set the value of variableflagto 1.

Step 2¶
- Create a
foreverloop and place an if statement under it. When the variableflagequals to 1, then activate the function. - Set time delay and play the built-in music
nyanfor once. Then set the variableflagto 0.

Program¶
- Link of the whole program: https://makecode.microbit.org/_35iVK1WVe8ms
- You can also download the program from the page below.
