Countdown Counter (II)
Use loops to repeat a set of block 100 thousand times!
- 1 x micro:bit
- 1 x USB cable
Since we’re building a countdown counter, we should be showing number 1000, 999, 998 and down to 1. This variation can be achieved with variables.
Create a new variable called countdown. Then, initialise its value as 1000.
In the loops drawer, drag out a repeat _ times block and place it within on start. Whatever blocks within it will be executed n-times - however many that you’ve indicated.
In the repeat body, we are going to do two things:
* Display the current value of countdown
* Decrement countdown by 1
To display the current value of countdown, place a show number_ inside the repeat _ times block. Drag in a countdown block from the variable drawer and place it inside show number_
Then, to decrease the countdown by 1, place change number by_ at the last line of the repeat _ times block. Type in -1 in the textbox.
And we are done! Feel free to change the number of repetitions to suit your needs!