In this lesson students will be creating a countdown timer using the micro:bit, innovation board and the speaker. Students will combine their knowledge of variables from the foundation lessons with logic and loops to create multiple variable numbers that interlink with each other.
Students will also create multiple input options as well as using forever loops.
- Understand how multiple variables can interlink with each other.
- Learn how to have multiple input options working alongside forever loops.
Download the Code
Click the button below to download the MakeCode editor code for this lesson. The hex file is contained in a zip folder.
Kindly refer to our download the code page for instructions on how to upload your code onto the micro:bit. Please use instructions set A.
This code can also be uploaded into the MakeCode editor.
- MicroUSB Cable
- 1 x Connector Cable
- Connect the micro:bit to the Innovation board via the edge connector.
- Connect the speaker to ADC1 using the connector cable.
- Connect the micro:bit to a computer via the microUSB cable.
- Go to the MakeCode website on your computer and open a new project.
Time to Code
What Will Happen
When the micro:bit is first powered a dot will appear on the LED matrix. This is to show that the countdown timer waiting to be assigned a time.
By default the assigned time is 10 seconds. The time can be changed to either 10, 20, 30 or 60 seconds by pressing button A. The time chosen will scroll across the LED matrix.
To start the countdown timer press button B. The LED matrix will turn on and slowly disappear over the duration of the countdown timer. The last 3 seconds will be counted with a beep from the speaker before finally when the countdown timer ends a melody will play on the speaker.
Keep in Touch
We would love to keep in touch with you and as a result aid you along your digital making journey.
Becoming a digital maker subscriber means you will receive exclusive offers and we will keep you up to date with new resources and kits, as well as upcoming events and workshops.
Let us know how your digital education journey is progressing. Send us pictures and videos of your awesome creations and use the hashtag below.