Updated: Mar 4, 2022
Following are the Steps for creating Dice Game
Click this link https://microbit.org/
Then click on official code editor Microsoft Make Code to do programming
Then click on New Project and give project name as Dice Game then this window will display
4. We need 3 pieces of code: one to detect a throw (shake), another to pick a random number, and then one to show the number.
5. First remove on start and forever block from editor workplace and From Input drag and drop on shake block onto the editor workplace. It runs code when you shake the mico:bit.
6. From Basic Get a show number block and place it inside the on shake lock to display a number
7. Put a pick random block from Math in the show number block to pick a random number
8. a Typical dice shows value from 1 to 6. So, in pick random, don't forget to choose the right minimum and maximum values ! (place minimum value as 1, and maximum value as 6 on pick random block)
9. if you have a micro:bit connected into a laptop/ pc/ mobile using USB then , Click on download button and transfer your code ( hex file) to the micro:bit and see the result.
10. The result is shown below: it will display the random number from 1 to 6 when you shake the mico:bit.