Appearance
LED灯控制
实验箱提供RGB三色led灯控制,包括一个红色led灯,一个绿色led灯,一个蓝色led灯。
该模块提供实验箱Led灯控制功能:
导入模块
typescript
import led from '@ohos.openvalley.led';
turnOn
turnOn(): boolean
亮起指定的led灯。
系统能力: SystemCapability.Sensors.EducationDeviceService
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
ledType | LedType | 是 | 指定Led灯 |
返回值:
类型 | 说明 |
---|---|
boolean | 执行成功/失败 |
示例:
typescript
// 亮起红色led灯
var result = led.turnOn(LedType.RED);
turnOff
turnOff(): boolean
熄灭指定的led灯。
系统能力: SystemCapability.Sensors.EducationDeviceService
参数:
参数名 | 类型 | 必填 | 说明 |
---|---|---|---|
ledType | LedType | 是 | 指定Led灯 |
返回值:
类型 | 说明 |
---|---|
boolean | 执行成功/失败 |
示例:
typescript
// 熄灭红色led灯
var result = led.turnOff(LedType.RED);
LedType
枚举,led灯类型。
名称 | 默认值 | 描述 |
---|---|---|
RED | 0 | 红色led灯 |
GREEN | 1 | 绿色led灯 |
BLUE | 2 | 蓝色led灯 |