← Micro:bit

Chapter 2

Displaying with the 5×5 LED Matrix

การแสดงผลด้วย LED 5x5

  • The 5 × 5 LED matrix (จอแสดงผล LED 5x5 จุด) is the micro:bit's screen: 25 red LEDs.
  • It can scroll words, show numbers, show 40 ready-made icons, show pictures you draw, and play animations.

2.1.1 Displaying Text & Numbers การแสดงตัวอักษรและตัวเลขบน LED 5x5

  • One block from the Basic group is enough to put words or numbers on the screen.
  • A word is too wide for 5 columns, so the micro:bit scrolls it from right to left.
Hello! the screen (5 × 5) text moves left
Scrolling: the 5 × 5 screen is a window, and the text slides through it from right to left.

Step-by-step: scroll some text

  1. Step 1 — Drag the block: take show string "Hello!" from Basic and drop it inside forever. Change the text if you like.
  2. Step 2 — Watch the simulator: "Hello!" slides to the left, over and over.
  3. Step 3 — Download: flash it to the board and the real LEDs do the same.

on start or forever?

⚡ Power on on start runs 1 time forever runs again and again ↻ loop e.g. a welcome sound, set a variable e.g. keep scrolling the text
on start runs once when the board powers up; forever then repeats until the power is switched off.

💡 Remember

  • show string inside on start → the message scrolls once.
  • Inside forever → it scrolls without stopping.
  • Put one-time jobs (a welcome sound, setting up) in on start; it always runs before forever.

Showing numbers with show number

show number 7 7 still show number 255 / -42 2 55 ⟵
One digit fits on the screen and stays still; anything longer scrolls like text.
  • One digit (0–9): shown in the middle, no scrolling.
  • Two or more digits, or a minus sign (e.g. 255, -42): scrolls right to left.

💻 2.1.1 Text and numbers — on start runs once, forever repeats

on start
show string START
show number 3
show number 2
show number 1
forever
show number 0
See it in JavaScript
basic.showString("START")
basic.showNumber(3)
basic.showNumber(2)
basic.showNumber(1)
basic.forever(function () {
	basic.showNumber(0)
})

Next: 2.1.2 Icons & 5x5 Matrix Graphics →

2.1.2 Displaying Graphics on 5x5 LED Matrix การแสดงกราฟิกบน LED 5x5 จุด

  • MakeCode has 40 ready-made icons.
  • If none fits, draw your own picture LED by LED.

Part 1: Preset icons การแสดงไอคอน

  1. Step 1 — Open Basic: click the Basic group in the block palette.
  2. Step 2 — Place show icon: drag show icon inside forever.
  3. Step 3 — Pick the picture: click the block's dropdown and choose one of the 40 icons.

💻 2.1.2 Preset icons — one block, 40 pictures

forever
show icon
pause (ms) 500
show icon
pause (ms) 500
show icon
pause (ms) 500
clear screen
pause (ms) 500
See it in JavaScript
basic.forever(function () {
	basic.showIcon(IconNames.Heart)
	basic.pause(500)
	basic.showIcon(IconNames.Happy)
	basic.pause(500)
	basic.showIcon(IconNames.Yes)
	basic.pause(500)
	basic.clearScreen()
	basic.pause(500)
})

All 40 icons, exactly as the LEDs show them ไอคอนสำเร็จรูป 40 แบบ

The name under each picture is the one in the show icon dropdown.

heart
หัวใจ
small heart
หัวใจดวงเล็ก
yes
เครื่องหมายถูก
no
กากบาท
happy
ยิ้ม
sad
เศร้า
confused
สับสน
angry
โกรธ
asleep
หลับ
surprised
ประหลาดใจ
silly
ทะเล้น
fabulous
ใส่แว่นเท่
meh
นิ่งเฉย
t-shirt
เสื้อยืด
roller skate
โรลเลอร์สเกต
duck
เป็ด
house
บ้าน
tortoise
เต่า
butterfly
ผีเสื้อ
stick figure
คนกางแขนขา
ghost
ผี
sword
ดาบ
giraffe
ยีราฟ
skull
หัวกะโหลก
umbrella
ร่ม
snake
งู
rabbit
กระต่าย
cow
วัว
quarter note
โน้ตตัวดำ
eighth note
โน้ตเขบ็ต
pitchfork
ส้อมสามง่าม
target
เป้า
triangle
สามเหลี่ยม
left triangle
สามเหลี่ยมชี้ซ้าย
chessboard
กระดานหมากรุก
diamond
ข้าวหลามตัด
small diamond
ข้าวหลามตัดเล็ก
square
สี่เหลี่ยม
small square
สี่เหลี่ยมเล็ก
scissors
กรรไกร

Part 2: Draw your own picture การสร้างกราฟิกด้วยตนเอง

x → y ↓ 01234 01234 0,0 2,1 4,4
Every LED has an address (x, y): x counts columns from the left, y counts rows from the top, both starting at 0.
  1. Step 1 — Place show leds: put show leds inside forever.
  2. Step 2 — Click the squares: a click switches that LED on; another click switches it off.
  3. Step 3 — Watch the simulator: it redraws your picture the moment you change a square.
show leds download
What you click in show leds is exactly what lights up.

💻 2.1.2 Draw your own — show leds, pixel by pixel

forever
show leds
pause (ms) 600
show leds
pause (ms) 600
See it in JavaScript
basic.forever(function () {
	basic.showLeds(`
		# . . . #
		. # . # .
		. . # . .
		. # . # .
		# . . . #
		`)
	basic.pause(600)
	basic.showLeds(`
		. . # . .
		. # # # .
		# # # # #
		. # # # .
		. . # . .
		`)
	basic.pause(600)
})

Next: 2.2 Animated Graphics (Stickman Animation) →

2.2 Animated Graphics การสร้างกราฟิกแบบเคลื่อนไหว

An animation needs only two things:

  • At least two different pictures (frames).
  • A short pause between them, so your eye sees movement.
Frame 1 pause 100 Frame 2 pause 100 forever: back to frame 1 ↻
Two frames take turns inside forever, so the stickman looks like he is running.

Step-by-step: the running stickman ขั้นตอนการสร้าง

  1. Step 1 — Place show leds: put show leds inside forever.
  2. Step 2 — Draw frame 1: light the first running pose (left picture below).
  3. Step 3 — Add a pause: snap pause (ms) 100 underneath. show leds already holds the frame for 400 ms; the pause adds 100 ms more.
  4. Step 4 — Duplicate: right-click show leds → Duplicate. The pause under it is copied too.
  5. Step 5 — Change frame 2: snap the copy on the end and redraw it as the second pose (right picture).
Step 2: frame 1
Step 5: frame 2
Frame 1 Frame 2 Frame 1 Frame 2 0 ms 500 ms 1000 ms 1500 ms 2000 ms show leds: 400 ms pause: 100 ms
Timeline: show leds holds each frame for 400 ms, then the pause adds 100 ms, so each frame is on screen for 500 ms (2 changes a second).

⏱️ show leds waits too

  • On a real board show leds keeps its picture for 400 ms before the next block runs.
  • So a frame stays on screen for 400 ms + the pause.
  • show icon waits 600 ms in the same way.

Try it: change the pause and work out each frame's time.

  1. Step 1 — pause 500: 400 + 500 = 900 ms per frame. The stickman walks slowly.
  2. Step 2 — pause 0: 400 + 0 = 400 ms per frame. Still easy to see, because show leds waits on its own.

Full MakeCode program

💻 2.2 Animation — frames and pause make him run

forever
show leds
pause (ms) 100
show leds
pause (ms) 100
See it in JavaScript
basic.forever(function () {
	basic.showLeds(`
		. . # . .
		. # # # .
		. . # . .
		. # . # .
		# . . . #
		`)
	basic.pause(100)
	basic.showLeds(`
		. . # . .
		. . # . .
		. # # # .
		. . # . .
		. # . # .
		`)
	basic.pause(100)
})

Next: Interactive Display Hardware Explorer →

Interactive Display Hardware Explorer

Hover over or tap a part of the real micro:bit V2 photo to learn what it does.

🔍

micro:bit V2 5×5 LED Matrix & Front Controls

Interactive Map
micro:bit V2 Front View - LED Matrix & Controls
👉

Hover or tap the 5x5 LED Matrix, Pixel (0,0), Logo, Button A, Button B, or Edge Connector to explore.

Next: Test Your Knowledge with the Quiz →

Chapter 2 Review & Self-Check

show icon
show leds
frame 1
frame 2

Check what you know about scrolling text, the 40 icons, LED coordinates and frame animation.

1. How many individual red LEDs make up the micro:bit display screen?
2. What happens if you place a `show string "Hello"` block inside `on start` vs inside `forever`?
3. How many preset graphic icons are included in the MakeCode `show icon` block drop-down?
4. Which MakeCode block allows you to toggle individual LEDs on and off to draw any custom pattern?
5. `show leds` then `pause (ms) 100`: how long does each frame stay on the screen?
6. What is the purpose of the `clear screen` block?
7. Which block lights one single LED at a row and column you choose?
8. Where is pixel (0, 0) on the 5×5 display?