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.
To see how this works, try the following program which lights up two LEDs.
# two_pixels from microbit import * display.set_pixel(0, 0, 9) display.set_pixel(1, 3, 4)
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.
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.
# 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)