In this video we’re making an electronic dice using the makecode microbit editor. We would expect this easy microbit project to take you 5 minutes or less to complete. Link below to our shared code project download.
Roll your micro:bit dice three times and comment your total score below.
The microbit has everything needed, a display to show the dice markings and a shake event. We’re going to start off showing numbers ( mild chilli challenge 🌶 ) then we will expand on this to replicate and show electronic dice faces ( spicy chilli challenge 🌶🌶 ).
You can grab the finished project here which we have shared on microbit.org
code: makecode.micro...
Showing the numbers is straight forward. The trouble is that the output does not really represent a dice so we then move on to expand the code and show the corresponding dice face. Points to look out for are ensuring that we load the dice face image array on startup, without this you’ll end up with an error when shaking the dice. You’ll also notice that because the first element of the list is indexed at zero our random number range changes from 1-6 to 0-5. Don’t forget when working on your own code to pause for thought on how to correctly index your own arrays and lists.
We test out the code using the on screen simulator and then load it onto a real micro:bit device for a hands on test.
Hot chilli challenge 🌶🌶🌶 can you improve on this code… perhaps add an animation to show the dice ‘rolling’ or why not link in the buttons or add a message on the display to guide a user on how to roll the micro:bit dice.
What Microbit project would you like to see us make next? Comment down below.
Giving the video a thumbs up and sharing it motivates us to make more videos like this for you to enjoy. If this is the first video you’ve seen on our channel then subscribe and turn on notifications to ensure you don’t miss our next upload.
How to make a dice 🎲 on your Microbit #microbitcoding #microbit #microbitproject micro:bit coding example project.
8 окт 2024