Custom Images
There are two ways you can create custom images from individual pixels on the micro:bit module’s display, the first by using the plot block in the more section of the Led category, or the second by using the show led in the basic category.
The plot method has three parameters: x, y, and brightness:
The arguments for x and y indicate the pixel’s position in the micro:bit module display’s coordinate plane. The brightness argument controls the brightness (0-255) of the pixel.
Example project: two_pixels
To see how this works, try the following program which lights up two LEDs.
- Enter, name, and flash the project two_pixels to your micro:bit.
How the two_pixels project works
The first block plot x (0) y (0) brightness (255) 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 255.
The second blockplot x (1) y (3) brightness (127) 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 127, so it is significantly dimmer than the first pixel.
Example project: medium_box
There’s a much easier way of setting the LEDs when you don’t care about the brightness of them. Using the following project, see how a medium-sized box can be made by lighting up 8 pixels in the middle of the micro:bit module’s display.
- Enter, name, and flash the project medium_box to your micro:bit
- It’s as easy as just clicking which squares you want to turn on.
Your Turn
- Try doing the same thing only using the plot command.
- Try creating a large box that uses all of the pixels on the outside edge of the display.
- Try making a program for a custom image of your own creation.