Example Code for micro:bit-Read Key Value (Math mode)

Last revision 2025/12/31

The article provides detailed instructions on using the micro:bit to read key values in Math mode, utilizing Makecode graphical programming and Mind+ platform. It includes hardware and software preparation, library installation, and sample code for key value reading, emphasizing the integration of touch keys on the automatic expansion board.

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

Read Key Value (Math mode)
Example Code in Math mode: calculator
Calculator
Key Value in math mode:

Key Label Value (numerical)
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
Key Label Vlaue (char)
+ +
- -
× ×
÷ ÷
= =
DFlogo DF

Result

When press down key 2, you get a number "2", then press down key 3, you get a number "23".

Was this article helpful?

TOP