Introduction: Fun MicroBit Dice

Hey! Today I will be sharing how to code a Micro bit Dice. Before that I will mention small info on what exactly is a Micro Bit. Micro bit is a technology designed by BBC. Mostly used for education in the UK. It is small and cariable yet loads can be done with one. Implemented with several features. Some cool ones are accelerometer, display of total 25 leds, proccessor and easy to charge with USB!

Getting to the point now! ☺️This coding that I did was quite tough to come out with at first. Tried several different ideas and failed. I was basically trying to make a different and fun dice that people would enjoy and different from the classic dice we use while playing. I also tried to experiment out on using many categories rather than cutting it to simple boring coding in order to challenge my coding. So after several tries I ended up with a clean coding that makes the dice different from classic ones. This Dice will count numbers from 1 to 6 like normal. But in games we all get very happy or sad with the numbers we get. So for that I made emojis to express the feeling of getting that number.

Things you will need:

1) A microbit- first thing!

2) A battery pack- for charging

3)Micro USB to USB cable- for the microbit to be connected to the computer

4)2 AAA batteries- will be needed to be put in the battery pack

So lets get started now!! :)

Step 1: Going to the Main Website

To get started first go to the page and press on Lets Code on top of the website Page.

Step 2: Using the Right Editor

So next you will find the Python editor and MakeCode editor. We will be using MakeCode editor for this program. So click the "lets code" orange button beside the MakeCode editor.

Step 3: Doing the First Block

At first you want to press the button Input on the left side. Use the block "button-A pressed". Under that I have inserted a block from the Variable. In the Variable categorie click the "make a variable" and type "Set dice to". After that go in to maths and drag the "0 + 0 "block. It will be the first block you will see after clicking on the maths categorie. On one of the "0" put a block called "pick random 0 to 0". I changed the pick random number to 1 to 5. Afterwards there is another "0' left on the left over there just change the number to "1". Now I basically took 6 numbers to be randomly chosen. You can put as many as you want to. Next we shall put 3 music blocks in all of which are named "Play tone 1 beat". You get to choose the sounds. I wished to go with Middle C, Middle F and Low F in order. I also went with just 1 beat but you can change according to your preference.

Next we will add another small part to it. So now we will use a block from the Basic catergorie. Drag the block "Show number". Then we shall make a variable "dice" and insert in place of the "0" in "Show number". Then use a variable "set dice to". Insert a Variable "set to dissapear" in the number place of the block previously inserted "set dice to". Do check the categories I have circled in the picture above to know which ones I used. Thus we are done with the first block!

Step 4: The Second Block

Now starting the second block we will again start with the input categorie first. We shall this time choose on "button B pressed". Then we will use a block "if true then" from Logic categorie and place it under the first block we chose earlier. Moving on we will use "clear screen" from Basic and insert under "If true then". You will spot a "+" sign under "if true then" which won't be in any need. All the blocks will be put under the first insert. To clear out if you have done it right do check the picture for accuracy. I decided to use a block from Loops next and I used the block "repeat 1 times do". I have circled around the categories I used in the picture above. So if you have any confusion on that just look at the picture.

Then adding a chunk of 7 "plot x,y" blockes from LED. By these I tried to create a smiley:) So down I will state the numbers I have plotted.

Plot: x:1 y:1; x:3 y:1; x:0 y:2; x:1 y:3; x:2 y:3; x:3 y:3; x:4 y:2;

If it is hard to follow the numbers then you can look at the numbers in the picture above as well. But also remember that this is to only create a smiley:) So if you plan to do any other icon or emoji or anything you can learn how to exactly do it by visiting this video I found online . So now we have completed with the second block!

Step 5: The Third Block

This block is very similar to the second one. We start of with "on shake" from Input firstly. Then similarly as the second block we will use a block "if true then" from Logic categorie and place it under the first block we chose earlier. We shall then use "clear screen" block from Basic. I used a block from Loops and I used the block "repeat 1 times do". Do check the circled categories in order for accuracy of the categories you are using.

Now I have created a sad face here, but used the same "plot x,y" from LED. So use 7 blocks of the block "plot x,y" and write them in specific numbers. The numbers I used was to create a sad face. I will state the numbers below.

Plot: x:1 y:1; x:3 y:1; x:0 y:4; x:1 y:3; x:2 y:3; x:3 y:3; x:4 y:4;

If you are confused on how to do some other icon just look at the video I put on the previous step. So the Third block is done!! ><)

Step 6: Done!!

Will give info on how to use it. Its very simple to use. Just press "A" to display the random numbers. Then press "B" or "shake the microbit" depending on if you are sad or happy. The B is for smiley thus happy and the shake is for sad face. Its super simple yet different and hopefully fun. At the end your coding should end up how the coding looks in the picture for it to work. Hope the tutorial was useful and informative and clear. I gave it my best. This idea has been done mostly be me. This was a great idea to share. The dice is fun and different from classic ones. Do try the Coding, its simpler than it even looks and mostly it works out perfectly!