Take a look at the program below, and try and work out what it does.
We have used all the blocks before....
Press the A button to see if your prediction was right
What do you think would happen if we changed the code in the start block to 'Set target to 5'?
(click to expand)
Here we have used a variable to store the number of times we want the loop to repeat.
In 'on button A pressed' block, we add 1 to the counter every time it goes through the loop and display the answer.
Watch the video below that demonstrates how to create a counter using loops and variables
Adapt the program above so that when you press A it counts up to the number of times you have pressed B.
Your program should do the following:
Press B any number or times.
Then press A, and the microbit will count to that number.
Write a program that will count down from 10 to 1.
Your program should do the following:
Press A to count down
A named place in memory where data can be stored and changed whilst a program is running.
Putting a piece of data into a variable
A programming structure that allows the code inside it to be repeated multiple times.
To repeat