Dice

Making a dice with a Micro:bit


YOU WILL NEED

Micro:bit
Laptop
USB-C cable


STEP 1

Connect Micro:bit to laptop.




Materials

Laptop
Micro:bit
USB-C cable



STEP 2

Access Makecode from your web browser at makecode.microbit.org




Materials

Laptop



STEP 3

Create a New Project and give your project a name.




Materials

Laptop



STEP 4

Drag the on shake block to your workspace.
Code blocks are colour-coded.
Find this block in the Input code drawer.




Materials

Laptop



STEP 5

Find and drag the show number block to your workspace and attach the show number block to the on shake event handler.
Look out for the yellow highlight on the notch.
Code blocks are colour-coded.
Find the show number in the Basic code drawer.




Materials

Laptop



STEP 6

Download program to Micro:bit.
Shake the Micro:bit and check that the number 0 is displayed on the Micro:bit.
Press the reset button on the back of the Micro:bit to reset the device.
Modify the program to show a different number and download it again.




Materials

Laptop
Micro:bit
USB-C cable



STEP 7

Drag out the random number generator block and place it within the previous number shown.




Materials

Laptop



STEP 8

Set the range for random numbers to be from 1 to 6.




Materials

Laptop



STEP 9

Download your program to the Micro:bit to test it out.
Shake the Micro:bit, and check that a number between 1 and 6 appears on the 5x5 LED display.
Press the reset button on the back of the microbit to reset the program.




Materials

Laptop
Micro:bit
USB-C cable


Code and References

Made this activity? Good Job! Now spread the word. Share a photo of your creation on social media with #letsgethacking #Dice