I created an unboxing video for the micro:bit where I explain a bit about how the device works and what can be done with it. I looked through a number of suggested projects, and I decided that a magic 8 ball program looked interesting to me.
When I actually coded it to begin with though, I found it was just much too simple. It worked perfectly well, but it needed a bit more flair. Now, when the program starts, it will produce a starting flash animation. I also decided that I wanted the response from the magic 8 ball to provide a graphic depending on whether it was an affirmative or negative response.
Here is a closer view of the code. When the program initially runs, it will create two arrays containing a list of text responses when the user shakes it and a corresponding value of either 1 or 0. When the device is shaken, the index variable is assigned a value between 0 and 7 corresponding to the indices in the text array.
The program then checks if the value of the true/false array is either a 1 or a 0 and displays a check mark or an “X” depending on which it is. After it shows this, it will clear the screen and print the message at the same index of the text array.