触摸LED#

介绍#

The Touch LED category includes blocks that control and monitor the VEX IQ (2nd gen) Touch LED. These blocks allow you to set color, brightness, and fade speed, as well as detect when the Touch LED is being pressed.

Below is a list of all blocks:

设置触摸 LED 颜色#

设置触摸 LED 颜色 块使用当前 转换速度亮度设置 设置触摸 LED 的颜色。

设定 [TouchLED 1 v] 颜色为 (none v)

参数

描述

触摸LED

在设备窗口中配置要设置的触摸 LED 颜色。

颜色

Sets the LED’s color to:

  • none — Turns off the Touch LED
  • red
  • green
  • blue
  • white
  • yellow
  • orange
  • purple
  • red violet
  • violet
  • blue violet
  • blue green
  • yellow green
  • yellow orange
  • red orange
You can also insert the Optical color name and Color color name reporter blocks to make the Touch LED match the color currently detected by the Optical Sensor or Color Sensor.

例子

当开始
[Blink the TouchLED off and on.]
永久循环
设定 [TouchLED 1 v] 颜色为 (green v)
等待 (0.5) 秒
设定 [TouchLED 1 v] 颜色为 (none v)
等待 (0.5) 秒

当开始
[See what color the Optical Sensor is detecting.]
永久循环
设定 [TouchLED 1 v] 颜色为 ([Optical 1 v] 颜色)
等待 (0.5) 秒

设置触摸 LED 淡入淡出#

设置触摸 LED 淡入淡出 块设置触摸 LED 在颜色之间转换的速度。

设定 [TouchLED 1 v] 变色速度为 [slow v]

参数

描述

触摸LED

设置触摸 LED 的转换速度,在设备窗口中配置。

过渡速度

触摸 LED 切换至下一颜色速度:

  • 关 – 颜色立即切换,无过渡。这是触摸 LED 的默认行为。6

例子

当开始
[Slowly fade TouchLED colors.]
设定 [TouchLED 1 v] 颜色为 (green v)
设定 [TouchLED 1 v] 变色速度为 [slow v]
等待 (2) 秒
设定 [TouchLED 1 v] 颜色为 (red v)

设置触摸 LED 亮度#

设置触摸 LED 亮度块设置触摸 LED 的亮度。

设定 [TouchLED 1 v] 亮度为 (50)%

参数

描述

触摸LED

在设备窗口中配置要设置的触摸 LED 亮度。

亮度

触摸 LED 的亮度从 0 到 100 的百分比。

例子

当开始
[Light up the TouchLED with different brightnesses.]
设定 [TouchLED 1 v] 亮度为 (25)%
设定 [TouchLED 1 v] 颜色为 (green v)
等待 (2) 秒
设定 [TouchLED 1 v] 亮度为 (100)%

触摸 LED 按下了吗?#

The Touch LED pressed? block returns a Boolean indicating if a Touch LED is currently being pressed.

  • True — The Touch LED is being pressed.

  • False — The Touch LED is not being pressed

<[TouchLED 1 v] 按下了?>

参数

描述

触摸LED

要检查哪个触摸 LED,在设备窗口中配置。

例子

当开始
[Change the TouchLED color when it is pressed.]
设定 [TouchLED 1 v] 颜色为 (green v)
等到 <[TouchLED 1 v] 按下了?>
设定 [TouchLED 1 v] 颜色为 (blue v)

当触摸LED#

当按下或释放触摸 LED 时,当触摸 LED 块会运行附加的块堆栈。

当 [TouchLED 1 v] [pressed v]

参数

描述

触摸LED

要检查哪个触摸 LED,在设备窗口中配置。

行动

确定附加的块堆栈何时执行:

  • 按下
  • 释放

例子

当 [TouchLED 1 v] [pressed v]
[Turn green briefly when pressed.]
设定 [TouchLED 1 v] 颜色为 (green v)
等待 [2] 秒
设定 [TouchLED 1 v] 颜色为 (none v)