BBC Microbit
Objective of the lesson Use Block Editor to make electronic dice All of you will: Shake the Microbit to create a random number 0 to 5 Most of you will: Display dice images for numbers 1 to 6 Some of you will: Create different dice e.g. an 8 sided dice
Electronic Dice 2 Program the Microbit so that when it is shaken a dice image comes up randomly Add an ‘on shake’ loop Add a variable called item Change the name of the variable to be RandomNumber
Set the RandomNumber variable to be either 0,1,2,3,4,5 An If do, else condition
Add if RandomNumber = 0 This will show the dice image of the number six (because we do not have a random number 6)
Click on the cog and add in an ‘else if’. If the RandomNumber = 1 It should display the dice image of a 1
Challenge Continue to add else if statements in for the remaining numbers Modify the code so that the dice only shows numbers 1,2 or 3 Modify the code so that the dice only shows numbers 1,2,3,4,5,6,7 or 8
Answers