BBC Micro:bit

Bits and Pieces

Learn It

  • Back in the early 1980s, the BBC launched a computer literacy project, working with a company called Acorn to produce a computer called the BBC Micro.

microkeyboard.jpg

  • (Image courtesy of Wikipedia)
  • The machines were highly popular with schools, and were many people's first experience with computers. They could be programmed using a language called BASIC, and had different games and programs that could be run on them. You can read more about it here.
  • Fast-forward 30 years or so, and the BBC have kindly produced the BBC Micro:bit - a computer you can carry, being given to every year 7 in the country to keep (you can take yours home once you've completed this topic).

Try It

  • Go to your desktop
  • Open the program called "Mu Editor"
  • copy and paste the following code to the window to replace all existing content.
# Add your Python code here. E.g.
from microbit import *

while True:
    display.scroll('Hello, World!')
    display.show(Image.HEART)
    sleep(2000)
  • Click on "flash" to download the code to your Micro:bit
  • Click "ok" to the subsequent popup window
  • You should see your code running on the Micro:bit
  • To save your code as a Python code file, you click on the "save" button.
  • To load an existing Python code for your Micro:bit, click on the "load" button.

Learn It

  • Let's think about what the program you've got running is actually doing for a second. Here is is again:
# Add your Python code here. E.g.
from microbit import *

while True:
    display.scroll('Hello, World!')
    display.show(Image.HEART)
    sleep(2000)
  • The first line starts with a # symbol. This tells MicroPython that this line is a comment written for humans to read. Any line you put a # at the start of will be ignored by the Micro:bit.
  • The from microbit... line is fetching some special code to allow our programs to control the buttons and LEDs on the Micro:bit. You'll always need this line at the start of the programs you write.
  • The while True line starts something called a loop, which you'll have encountered before in scratch. We won't focus too much on this in our first lesson, but these are important in programming and we'll re-visit them later on. For now, its enough to know that any lines of code that come after it AND are indented (see how the next instructions are a few spaces away from the left margin?) will be repeated over and over forever.
  • The display.scroll() line asks the Micro:bit to display whatever text is written in quotes inside the brackets on the LED display.
  • display.show() makes images appear on the display. A heart is built into Micro:Python, as are rather a lot of others too.
  • sleep() tells the Micro:bit to wait a number of milliseconds (there are 1000 in 1 second) before carrying out the next instruction.

Badge It

  • Silver: Write a program to do the following, and push it to your Micro:bit
    • Display your first name,
    • Wait 1 second,
    • Display an image,
    • Wait 1 second,
    • Display "CompSci"
    • Wait 1 second
  • Take a screenshot of your code, and upload it to BourneToLearn for marking
  • Gold: Read the documentation for DIY images, and draw a custom shape on the Micro:Bit. Upload a screenshot of your code for the teacher.
  • Save your work in your H: drive using the technique above.