LED指示灯#

介绍#

led 类允许 V5 主控模块使用 3 线端口打开或关闭连接的发光二极管 (LED)。

绿色 VEX V5 LED 指示灯。

类构造函数#

led(
  triport::port &port );

类析构函数#

销毁 led 对象并释放相关资源。

virtual ~led();

参数#

范围

类型

描述

port

triport::port &

LED 指示灯连接的 3 线端口,写成 Brain.ThreeWirePort.X 或 ExpanderName.X,其中 X 是端口字母(例如, Brain.ThreeWirePort.A 或 Expander1.A)。

示例#

// Create an led instance in Port A
led LEDA = led(Brain.ThreeWirePort.A);

成员功能#

led 类包含以下成员函数:

  • on — 打开指定的 LED 指示灯。

  • off — 关闭指定的 LED 指示灯。

在调用任何 led 成员函数之前,必须先创建一个 led 实例,如下所示:

/* This constructor is required when using VS Code.
LED Indicator configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create an led instance in Port A
led LEDA = led(Brain.ThreeWirePort.A);

on#

打开指定的LED指示灯。

Available Functions
void on();

Parameters

此函数不接受任何参数。

Return Values

此函数不返回值。

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

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

// Turn off LED
LEDA.off();

off#

关闭指定的LED指示灯。

Available Functions
void off();

Parameters

此函数不接受任何参数。

Return Values

此函数不返回值。

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

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

// Turn off LED
LEDA.off();