LED显示屏

BBC micro:bit上的LED显示屏包含了25颗红色的LED灯。这些灯呈5x5的网格状排列(横排5颗LED灯,竖排5颗LED灯)。

BBC micro:bit 25颗LED灯全部都被点亮

 

哪个LED ?

使用 x, y 坐标来指定在网格中特定的 LED ; 其中 x 是的水平位置,y 是垂直位置(0,1,2,3,4)。 将micro:bit像信用卡一样水平地放置(见上图),找出 xy 坐标。

这是5 X 5 方格中指示灯的x,y坐标︰

0, 0 1, 0 2, 0 3, 0 4, 0

0, 1 1, 1 2, 1 3, 1 4, 1

0, 2 1, 2 2, 2 3, 2 4, 2

0, 3 1, 3 2, 3 3, 3 4, 3

0, 4 1, 4 2, 4 3, 4 4, 4

The x, y coordinates for the LED in the centre of the grid are 2, 2. Starting from 0, 0 count over 2 columns and then down 2 rows.

行,列 -1

Since the row and column numbers start at 0, an easy way to figure out the x, y coordinates is to subtract 1 from the row and column number (when counting from 1). In other words, to specify the LED in the 4th column 5th row, subtract 1 from each number to get coordinates 3, 4.

LED编程

MakeCode编辑器

LED 打开/关闭

Use + 绘制 and 不绘制 to turn an LED on or off.

一个 LED 是打开还是关闭?

Use the point function to find out if a LED is on or off.

显示图像、 字符串和数字

Instead of turning individual LEDs on or off, as above, you can display an image directly to the screen or show text/numbers on screen using the show number/show string function.

Python

See the images section of the documentation to learn more about programming the LEDs in Python for micro:bit.

Selecting this opens external content from our support system, which adheres to their privacy policy.