Skip to content

Display DIY Images

Level Beginner
Board V1 & V2
Parts micro:bit

What you'll build

Design a custom image — a little boat — by describing the brightness of every LED.

Code

3 display DIY images.py
'''
Example: Display DIY Images on LED matrix in micro:bit
By: Meqdad Darwish
Ref: https://microbit-micropython.readthedocs.io/en/latest/tutorials/images.html#diy-images
'''
from microbit import *

boat = Image("06050:"
             "07040:"
             "08030:"
             "99999:"
             "09990")

display.show(boat)

How it works

An Image can be built from a string of five rows separated by :. Each digit is one LED's brightness, from 0 (off) to 9 (brightest), so "99999" is a fully lit row and "06050" lights two LEDs dimly.

Try this next

  • Draw your initials or a small animal.
  • Make two frames and alternate them to animate the boat rocking.
  • Use display.set_pixel(x, y, brightness) to change a single LED.