引领#
初始化 led 类#
使用以下构造函数创建一个 led 对象:
led
构造函数在指定的三线端口中创建一个 led 对象:
范围 |
描述 |
---|---|
|
必须先创建 Brain 或 3-Wire Expander,然后才能使用 led 类构造函数创建对象。
// Create the Brain.
brain Brain;
// Construct an LED "LED" with the led class.
led LED = led(Brain.ThreeWirePort.A);
当引用 led 类方法时,此“LED”对象将在整个 API 文档的所有后续示例中使用。
类方法#
在()#
on()
方法打开 LED。
**返回:**无。
// Turn on the LED.
LED.on();
// Wait 2 seconds.
wait(2, seconds.);
// Turn off LED.
LED.off();
离开()#
off()
方法关闭 LED。
**返回:**无。
// Turn on the LED.
LED.on();
// Wait 2 seconds.
wait(2, seconds);
// Turn off LED.
LED.off();