Magic 8-Ball MicroPython Code for BBC Micro:bit

I’ve been messing around with the online editors on the micro:bit website for a while now, and while they are great for beginners, I was looking for a dedicated offline client for Windows. Turns out there’s this great little programme called Mu, which let’s you code in MicroPython, a subset of the Python 3 programming language.

I started out with a basic script which emulates a Magic 8-Ball and includes all the original answers from the retail version. The basis of the code is simple: Use the random command to select a string from a list of 20, then scroll it along the LED matrix.

This first version works by a simple tap of the A button. For those who have a speaker attached, it will also play a sound effect before delivering the answer. In the future I hope to add motion detection to replace the A button activation.

If you’d like to download this to try on your micro:bit then feel free to grab the source code here:

(Save Target as):

Leave a Reply

Your email address will not be published. Required fields are marked *