2.6. LED Display - Images#

2.6.1. Showing Static Images#

You can show images on the display such as:

  • strings

  • numbers

  • arbitrary patterns

The function show will put various objects on the display

microbit.display.show(image, delay=400, wait=True, loop=False, clear=False)

where:

  • image is:

    • a str, float or int in which case each character (or digit), is called an image, will be shown in sequence on the display

    • an Image or list of Image which specifies the intensity of each pixel individually

  • delay is the milliseconds between each image

  • wait determines whether the function will block execution of code until the animation is finished

  • loop can be enabled to infinitely loop the animation

  • clear can be set to clear the display after it has finished

2.6.2. Images#

The Image class is designed to hold a single image shown on the display and allows you to defined your own custom images.

To construct an image you must pass a string containing each pixels brightness, with : (colon) to separate each line.

Example#

from microbit import *

image = Image("90009:09090:00900:09090:90009:")

microbit.display.show(image)

which would be displayed an “X” on the 5x5 grid as:

90009
09090
00900
09090
90009

Built-in Images#

There are a number of built-in images provided for you such as:

  • Image.HEART

  • Image.SMILE

  • Image.YES

All built-in images are listed here https://microbit-micropython.readthedocs.io/en/v2-docs/microbit_micropython_api.html#images

2.6.3. Scrolling Text#

Instead of showing a single image at a time, you can scroll them across the display using scroll

microbit.display.scroll(text, delay=150, wait=True, loop=False, monospace=False)

where

  • delay controls how fast the text is scrolling