Micro:bit Intro

The version of Python the Micro:bit uses is called MicroPython and contains a vast array of commands. The online code editor for this can be found here.

Basic Display Commands

Scrolling Messages

from microbit import * #Import the library needed for the microbit
while True:
    display.scroll('Hello, World!') #The show scrolling messages
    sleep(2000) #Sleep for 2 seconds - use milliseconds 

Student Activity

  1. Open the code editor for MicroPython.
  2. Write a simple program to display your name on the Micro:bit
  3. Download the program to your Micro:bit and test it works

Stretch: Modify your code so that it displays a second message after your name

Displaying Images

The Micro:bit has 25 LED's which can be used to display simple images on the screen, MicroPython comes equipped with inbuilt commands to display several objects.

from microbit import *
display.show(Image.HAPPY)#show command to display the image happy

Student Activity

  1. Open the code editor for MicroPython.
  2. Write a program to display the happy image on your Micro:bit.
  3. Download the program to your Micro:bit and test it works.
  4. Use the Micro:bit guide to test out displaying other images.

Stretch: Modify your code so that it displays a different image after 10 seconds

Making Your Own Images

Making your own images is easier than you might think, each of the 25 LED's can be turned on or off individually, you can also control how bright the LED is when it is switched on.

0 = Off

1 = Dim

9 = Full brightness

With the numbers in between slowly increasing the brightness level

from microbit import *
chair = Image("00005:00005:55555:09090:09090") #Each number = 1 LED
display.show(chair)

Student Activity

  1. Open the code editor for MicroPython.
  2. Write a program to draw your own image
  3. Download the program to your Micro:bit and test it works.

Stretch: Modify your code so that it displays a different image after 10 seconds