Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Writing micro:bit programs

Writing micro:bit programs

Custom Images

You can create custom images from individual pixels on the micro:bit module’s display by using display.set_pixel. 

The set_pixel method has three parameters: x, y, and b:

    display.set_pixel(x, y, b)

The arguments for x and y indicate the pixel’s position in the micro:bit module display’s coordinate plane. The b argument controls the brightness (0-9) of the pixel.

Example script: two_pixels

To see how this works, try the following program which lights up two LEDs.

  • Enter, name, save, and flash the script two_pixels to your micro:bit.
# two_pixels

from microbit import *

display.set_pixel(0, 0, 9)
display.set_pixel(1, 3, 4)

How the two_pixels script works

The first statement display.set_pixel (0, 0, 9)lights up the pixel is located at (0,0) which is the top left of the display. It is set to the maximum brightness of 9.

The second statement display.set_pixel (1, 3, 4)  lights up the pixel located at (1,3), which is in the second column from the left and down 4 rows. The brightness is only 4, so it is significantly dimmer than the first pixel.

Example script: medium_box

Using the following script, see how a medium size box can be made by lighting up 8 pixels in the middle of the micro:bit module’s display.

  • Enter, name, save, and flash the script medium_box to your micro:bit
# medium_box

from microbit import *

display.set_pixel(1, 1, 9)
display.set_pixel(1, 2, 9)
display.set_pixel(1, 3, 9)
display.set_pixel(2, 1, 9)
display.set_pixel(2, 3, 9)
display.set_pixel(3, 1, 9)
display.set_pixel(3, 2, 9)
display.set_pixel(3, 3, 9)

Your Turn

  • Try creating a large box that uses all of the pixels on the outside edge of the display.
  • Try writing a program for a custom image of your own creation.

Printer-friendly version
Premade Images
Prev
Remember and Use Values
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress