Countdown Counter (II)

Use loops to repeat a set of block 100 thousand times!


You'll need

  • 1 x micro:bit
  • 1 x USB cable

Step 1

Instructions

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.


Step 2

Instructions

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.


Step 3

Instructions

In the repeat body, we are going to do two things:
* Display the current value of countdown
* Decrement countdown by 1


Step 4

Instructions

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_


Step 5

Instructions

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!


Code and References

Completed this tutorial?

Spread the word! Let's get this trending on social media with #letsgethacking #CountdownCounter(II)