The micro:bit has a 5x5 LED matrix built in. This is the main output device on the board. You can light up multiple LEDs to make patterns or scroll text. You can also light up the individual LEDs and set the overall brightness of the matrix.
On this page, we'll just get ourselves started with some simple uses of the matrix.
Displaying An Image
Plug in your micro:bit. Go to the micro:bit web site and follow the hyperlink to Create Code. Choose the Microsoft Block Editor and select to make a New Project.
Look in the Basic section for the show leds block. Drag it into the code window and click on some of the checkboxes to make your pattern.
Click on Run and you can see a preview of the image on the right hand side of the page.
Click on Compile to make a .hex file for the micro:bit. When you do this, you are prompted to download the file. Either choose to save the file directly to the micro:bit (which shows up as a drive when plugged into the PC) or save the file and then copy to the micro:bit.
We can make the image blink on and off if we add a few more blocks to our script.
Preview your blinking pattern in the code editor before compiling and downloading to the micro:bit.
By chaining a series of images, you can create an animation. Here is a simple example. You can probably do much better than this if you spend a little time thinking.
There is a delay between each image. The pause block accepts a number of milliseconds and causes the microcontroller to wait for that amount of time before processing the next instruction. You probably want the same length of pause between each frame of your animation. If you make and set a variable in your script, it is easier to experiment with the timings since you only have to change a single value.
There is a block that allows you to display text on the matrix. The text will scroll from right to left across the matrix.
You can turn the LEDs off and on individually. Try this code. It uses a for loop to light up the LEDs in the top row, one at a time, from left to right.
Adding another loop, we can make it go through the whole matrix,
Unplotting the pixel means turning it off. Adding code to do that and our LEDs light one-by-one from the top left to the bottom right, row by row.
Using the set brightness block, you can manipulate the brightness of the LEDs in your scripts. A loop is used in this example to increase the brightness gradually.