writeLED
Write to BBC micro:bit LED
Description
displays data on BBC micro:bit board LED matrix or flashes a specific LED, using a microbit
object.writeLED
(microbitObj
,data
)
displays
data on BBC micro:bit board LED Matrix or flashes a specific LED, using a microbit object,
with an additional option to include the scrolling speed as a name-value pair.writeLED
(microbitObj
,data
,Name,Value
)
Examples
Write Data to the LED
Write "X
" on the LED matrix of BBC micro:bit
hardware connected to the COM4
port, and define the scrolling speed as
5 columns per second (scrolling speed as 5).
m = microbit('COM4'); data = [1 0 0 0 1;0 1 0 1 0;0 0 1 0 0;0 1 0 1 0;1 0 0 0 1]; writeLED(m,data,'ScrollingSpeed',5);
Input Arguments
microbitObj
— BBC micro:bit hardware connection
microbit object
BBC micro:bit hardware connection, specified as a microbit object.
data
— Data to be displayed
character string | scalar | vector | matrix | MicrobitImages
.image name
Data to be displayed on the LED matrix. Valid inputs are:
character string — Lights the LEDs based on the text or character mentioned.
scalar — Lights a single LED using linear addressing.
vector — Lights a single LED, defined using a 1-by-2 vector that gives the horizontal and vertical coordinates of the LED to be lit.
matrix — One of the following:
MATLAB® matrix functions like
ones
,eye
, and so on, which represent a pattern of ones in an array. A limit of 5-by-5 needs to be considered if you are using these functions to create the matrix.A 5-by-n matrix, where n ≥ 5, and the matrices created using MATLAB functions like
horzcat
, which represent concatenation of arrays. You need to specify the scrolling speed so that all the columns scroll in the display.
Note
In the matrix, a value of 0 indicates that the LED is off, and a value of 1 indicates that the LED is on.
MicrobitImages
.image name — An image from the BBC micro:bit library. The following table shows the supported names of images based on the category.Image Names
Category Name of Image Face HappyFace SadFace NeutralFace ShockedFace SurprisedFace Arrow with direction ArrowNorth ArrowNorthEast ArrowEast ArrowSouthEast ArrowSouth ArrowSouthWest ArrowWest ArrowNorthWest Dice OneOnDice TwoOnDice ThreeOnDice FourOnDice FiveOnDice SixOnDice All upper case letters A ….…... Z All lower case letters a ….….…. z All single digit numbers Zero One Two .….. Nine Heart Heart FilledHeart
Note
Float data types like single and double are not supported for the
data
argument.
Example: writeLED(m,"THIS is micro:bit", 'ScrollingSpeed',
5)
Example: writeLED(m, '>')
Example: writeLED(m, 'M')
Example: writeLED(m,7)
Example: writeLED(m,[2
2])
Example: writeLED(m, eye(5))
Example: writeLED(m, horzcat(eye(5),ones(5)), 'ScrollingSpeed',
4)
Example: writeLED(m, MicrobitImages.Heart)
Example: writeLED(m, MicrobitImages.M)
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example:
writeLED(obj,data,'ScrollingSpeed',3)
The name-value pair arguments for writeLED
are included after
obj
and data
inputs.
ScrollingSpeed
— scrolling speed of the LED display
1 to 10 | columns per second | double
Scrolling speed of the LED display on the BBC micro:bit board.
Version History
Introduced in R2017b
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)