LI: to understand block coding to control the actions of a MicroBit.
Today for Tech with Mrs Ferguson, we learnt how to code our MicroBot to randomly choose a number in order to play certain kinds of games. This coding was called Dice and Rock Paper Scissors hex.
First, we turned our MicroBit into a dice by using an ‘on shake’ block which shows the MicroBit that when it is shaken, a certain action must be taken. Inside of that block, we put a ‘show number’ block which means that when the MicroBit is shaken, it knows to choose a number. Next, we told the MicroBit which numbers to choose from and in this case, it was 1 to 6 because those are the numbers on the dice. Now, when the MicroBit is shaken, a random number from 1 to 6 is shown just like a dice.
Secondly, we learnt how to code our MicroBit to play rock paper scissors. Again, we used the ‘on shake’ block. Inside, we made a variable called ‘hand’ which is the name to our hex code. Inside of the variable we put a ‘pick random’ block with the numbers 1 to 3. Afterwards, we told the MicroBit that if the number appears as one, an LED on the MicroBit would know a square representing paper. If the number appears as two, an LED would show a circle representing rock. And lastly, if the number appears as anything other than 1 and 2, an LED would show a picture of scissors.
I enjoyed our final lesson with Mrs Ferguson because I expanded my knowledge on coding with blocks as well as python to give the MicroBit action instructions.