引领#

初始化 led 类#

使用以下构造函数创建一个 led 对象:

The led constructor creates an led object in the specified Three Wire Port:

范围

描述

port

LED 连接到的 3 线端口,无论它是 大脑 上的端口,还是 3 线扩展器 上的端口。

必须先创建 Brain3-Wire Expander,然后才能使用 led 类构造函数创建对象。

// Create the Brain.
brain Brain;
// Construct an LED "LED" with the led class.
led LED = led(Brain.ThreeWirePort.A);

This LED object will be used in all subsequent examples throughout this API documentation when referring to led class methods.

类方法#

on()#

The on() method turns the LED on.

**返回:**无。

// Turn on the LED.
LED.on();

// Wait 2 seconds.
wait(2, seconds.);

// Turn off LED.
LED.off();

离开()#

The off() method turns the LED off.

**返回:**无。

// Turn on the LED.
LED.on();

// Wait 2 seconds.
wait(2, seconds);

// Turn off LED.
LED.off();