pbaumgarten.com

Microbit Lesson 1: Getting started

Video

Introducing

The Microbit

Python

Mu Editor

Connecting your Microbit

Your first program

from microbit import *

# Display 'Hello world!' then the happy emoji
display.scroll("Hello world!")
display.show(Image.HAPPY)

(Demo)

Syntax of your first program

Features of your first program

Tips for correcting your programs (debugging)

When asking for help…

Your second program

We can use the sleep() command to create a pause in our program as the following demonstrates…

from microbit import *

display.show(Image.HAPPY)
sleep(2000)
display.show(Image.HEART)
sleep(2000)
display.show(Image.YES)
sleep(2000)

Your third program

We aren’t just restricted to the images already created for us, we can create our own with the Image() command.

For instance, if I woke up in the morning feeling sad, then felt neutral, then felt happy, I could show this with a Microbit. The neutral face doesn’t currently exist, so I need to create it myself as follows…

from microbit import *

display.show(Image.SAD)
sleep(2000)
display.show(Image("00000:09090:00000:99999:00000"))
sleep(2000)
display.show(Image.HAPPY)
sleep(2000)

The Image() command works by providing a brightness code for each individual LED on the board. 0 indicates LED off, 9 indicates LED full brightness on. We specifiy the five values for the five LEDs in each row, and use a : as a row separator.

Activity: Create an animated art piece

With time remaining create an animated art piece on the microbit.

You can use any mix of the commands shown so far.

For example: