The micro:bit is an educational and creative tool to inspire a new generation of young people. It can be used across the curriculum, not just in STEM subjects. It can help give young people the knowledge and skills to move from being consumers of digital information, to being designers and creators of new tools to enhance learning, to solve problems or just to have fun, enabling them to make the most of 21st Century life and the economy. To learn more click here.
In this section, you will learn how to make a virtual dice a real one (i.e. one that you can touch). But this dice will not only throw a number but will also send the resulting number to another micro:bit via Bluetooth. That is not all, the receiving micro:bit is connected to a PC with a java version of the scratch cliff erosion model. At the end of this exercise you will have learnt not only how to code a dice on Microbit, but also how to stream the resulting number, fetch it and use it as an input of your cliff model.
You will need the following materials to do this exercise:
The coding for creating a virtual dice with wireless streaming is very simple and can be downloaded from here microbit-rotating-dice.hex
Note you have to download the same .hex code to two microbits… one acts as a remote sensor, the second must be connected to your computer with a USB lead and acts as the radio receiver.
Download and unzip the CliffErosionApp.jar and its resource folders clifferosionapp_java.zip.
Open a MS-DOS command window and go to the folder you have just created that contains a file named CliifErosionApp.jar.
Connect one of the micro:bit unit to your computer with the USB cable and identify which COM port has been assigned to the micro:bit. You can find out the COM Port number using the Device Manager and looking at the Ports (COM & LPT). Annotate the number of the COM port that appears labelled as “mbed Serial Port (COM?)”, where ? will be an integer number.
Turn on the micro:bit unit with the battery pack and hide it within the foam dice. If you want that the dice number coincide with the number through out by the micro:bit you have to orientate the microbit in the same way than shown in the picture below.
Type the following command to execute the jar file: java -java CliffErosionApp.jar
The program will then ask you to enter the COM port number at which the micro:bit unit is connected. If your COM port is, for example, number 5 you should type “COM5” and click enter to the program to start.
Throw the dice and see what happen with the house at the top of the cliff!