Illustration: at a school desk a child holds a micro:bit showing a dice five on its LEDs.Games
Illustration (made with AI): roughly what the finished project looks like.

A Digital Dice with micro:bit

Shake the micro:bit and a random number from 1 to 6 appears on its display. A first program in 15 minutes, fine for children too.

Difficulty
Beginner
Time
15 min
Age
8+
Parts
1, 1 on the site

Written by the RoboHub team. A question? Write to us.

Variations

Choose a variation and the parts list updates.

Instructions

  1. Open MakeCode

    Open makecode.microbit.org in your browser. Nothing to install.

  2. Build the blocks

    Put “show number” inside the “on shake” block, and “pick random 1 to 6” inside that. In Python the same looks like this:

    Python
    def on_gesture_shake():
        basic.show_number(randint(1, 6))
    
    input.on_gesture(Gesture.SHAKE, on_gesture_shake)
  3. Download it

    Connect the micro:bit by USB and download the program. Copy the file onto the micro:bit as you would onto a USB stick.

  4. Play

    Plug a battery holder (2 × AAA) into the board and the dice is ready.

    Illustration: a micro:bit showing a dice five on its LEDs, next to two real dice.

    Illustration, made with AI

  • Games
    Beginner45 min10+

    A Two-Player Reaction Game

    An LED lights at a random moment. Whoever presses their button first wins. Built from Student Kit parts in 45 minutes.

    6/6 parts on the site
  • Games
    Beginner40 min8+

    A Little Button Piano

    Five buttons, five notes: C, D, E, F and G. Press a button and the buzzer plays its note, enough for simple tunes.

    5/5 parts on the site
  • Sensors
    Beginner1 h10+

    Parking Sensor with Sound and Lights

    An ultrasonic sensor measures the distance. Three LEDs show how close the obstacle is, and the buzzer beeps faster the closer you get.

    6/6 parts on the site