Example Code for micro:bit-Countdown Timer

Last revision 2025/12/31

This article provides detailed instructions on setting up a countdown timer using micro:bit and Makecode, including hardware and software preparation, with integrated RGB LEDs showing random colors as part of the timer operation.

Hardware Preparation

  • Math & Automatic expansion board for micro:bit, Quantity: 1
  • micro:bit, Quantity: 1

Software Preparation

Makecode graphical programming, Mind+ platform.
Makecode Library Address.
About how to install a software library?

Wiring Diagram

No specific wiring required (touch keys are integrated on the board).

Other Preparation Work

Install the Makecode library from https://github.com/DFRobot/pxt-Math-Automatic.
About how to install a software library?

Sample Code

Countdown Timer
Countdown Timer Example Code Download

Result

Every RGB LED shows random color in each turn. When all LEDs turns off in one turn, we mark it as 16s. The related time will be displayed on micro:bit LED matrix. Unit: second.

Was this article helpful?

TOP