The BBC Microbit is such a versatile entry point to programming and there are already some excellent resources that you can use to get going with it straight away. But at the STEAMShip, we are really excited about how we might explore different ways to integrate it in your projects beyond the excellent resources that are available on the BBC Microbit website.
Besides using the existing editors such as the Blocks editor and Python editor that work as apps running from the BBC Microbit website in a web browser, you can choose to download the Apple or Android BBC microbit app, details of which can be found on the official Microbit site..
But there is another option. There is also a nice little piece of software which can be downloaded and installed on your computer from the creators website or from Github directly. Its great if you feel more comfortable using a simple text editor with the Microbit and more importantly want to save all of your creations to your computer. It also works with Windows, OSX and Linux.
So how do you use it? When you open the software, you are faced with a simple interface with some circular icons at the top for performing common tasks. The first bank consists of basic file management options, but the second bank has options for uplodading code to the microbit – called flashing, a files icon for viewing files on the Microbit and a replace function which allows for realtime editing of files. There are options for zoom in and zoom out to increase or decrease the text size followed by a check option which checks your code for errors. From here you can change the theme from a light to dark option, look at the help files or quit the programme. But its basically a simple editor to code your BBC Microbit using python.
But how do you know what code to put in it? Well the BBC microbit has a very useful documentation section for all the python commands you can use to programme the Microbit. It can be found here. So to get started we could set up a simple hello world example.
If you visit the link for the documentation and look down the menu on the left side of the page you will find the “Hello World” section. If you click on the link you will see the code snippet for a Hello World script with some detailed explanations and an animated visual of what you might see if you uploaded it to your Microbit.
So if we tried to replicate that by using Mu, you will see how easy it is to use. In the video below, we uploaded (flashed) the “Hello World” code which we took from the Microbit Documentation page. As you can see in the video it shows the flashing progress on the Mircrobit indicated by the Yellow light. Once loaded it displays the “Hello World” script on the Microbit.
If you try this and it doesn’t work first time, then use the Check function on the Mu editor to make sure there aren’t any errors. Its possible that you just need to press return at the end of the script as python is a bit fussy about line endings, indentation and returns.
If it works ok first time, great. Time to do some more interesting things. If you visit the Microbit documentation page again, scan down through the menu on the left side of the page to find some more interesting examples to play around with. As we experiment further, we’ll post up some interesting examples.
For example if you visit the Speech section on the BBC Microbit documentation page, you’ll find all kinds of information about the speech synthesis functions of the microbit. Try copying and pasting examples from this page to see what they do on the BBC Microbit. Don’t forget to add
import speech at the top of your script otherwise the speech functions won’t be understood.
Here is a quick example of us playing around with the speech functions.
Here is the script used in this example.
from microbit import * ##Tells the microbit to import all available libraries import speech vox = [ "#52AOAOAOL", "#52AER", "#58AWND", "#52THEH", "#44WERER", "#52LD", "#52AER", "#58AWND", "#52THEH", "#35WERER", "#52LD", "#52AER", "#58AWND", "#52THEH", "#44WERERLD", "#52AER", "#58AWND", "#52THEHEHEHEH", ] ## Pitch values and Phonemes for "All around the world around the world . . ." anothersong = [ "#115DOWWWWWW", # Doh "#103REYYYYYY", # Re "#94MIYYYYYY", # Mi "#88FAOAOAOAOR", # Fa "#78SOHWWWWW", # Soh "#70LAOAOAOAOR", # La "#62TIYYYYYY", # Ti "#58DOWWWWWW", # Doh ] ## Pitch values and Phonemes for "Do re me fa so la ti do . . ." while True: ##While loop if button_a.is_pressed(): ##while button a is pressed display.show(Image.HAPPY) ##show happy image song = ''.join(vox) ## Join together vox array speech.sing(song, speed=100) ##speak song elif button_b.is_pressed(): ##while button b is pressed display.show(Image.MUSIC_QUAVERS) ##show music quavers image song2 = ''.join(anothersong) ##join anothersong array speech.sing(song2, speed=100) ##speak song else: display.show(Image.SAD) ##otherwise show sad image (if nothing is pressed) display.clear()
Leave A Comment
You must be logged in to post a comment.