引领#

介绍#

VEX AIM 编码机器人配备可编程 LED(发光二极管),可根据项目情况改变颜色。这些 LED 可以单独设置,也可以同时设置,以提供视觉反馈或指示机器人状态。

LED名称:

带有风扇的机器人自上而下的图标从 11 点钟位置的 LED 位置出现。
LED1

带有风扇的机器人自上而下的图标从 9 点钟位置的 LED 位置出现。
LED2

带有风扇的机器人自上而下的图标从 7 点钟位置的 LED 位置出现。
LED3

带有风扇的机器人自上而下的图标从 5 点钟位置的 LED 位置出现。
LED4

带有风扇的机器人自上而下的图标从 3 点钟位置的 LED 位置出现。
LED5

带有风扇的机器人自上而下的图标从 1 点钟位置的 LED 位置出现。
LED6

机器人的自上而下的图标带有风扇,从所有六个 LED 的位置冒出,顺时针方向位于 1、3、5、7、9 和 11 点钟位置。
ALL_LEDS

  • on – Turns one or all LEDs on and sets their color.

  • off – Turns one or all LEDs off.

行动#

on#

on sets the color of one or all of the robot’s LEDs.

Usage:
robot.led.on(led, color)

范围

描述

led

The LED or LEDs to turn on. You can use a single LED like LED1, all LEDs with ALL_LEDS, or a group of LEDs in a tuple like (LED1, LED2). See all available LED names here.

color

Optional. Sets the LED color. Options include:

  • BLACK
  • BLUE
  • CYAN
  • GREEN
  • ORANGE
  • PURPLE
  • RED
  • TRANSPARENT
  • WHITE (default)
  • YELLOW
You can also specify a custom color.

# Turn LEDs green while the screen is pressed
while True:
    if robot.screen.pressing():
        robot.led.on(ALL_LEDS, GREEN)
    else: 
        robot.led.on(ALL_LEDS, BLACK)

    wait(50, MSEC)

# Turn two LEDs red
robot.led.on((LED3, LED4), RED)

off#

off turns off one or all of the robot’s LEDs.

Usage:
robot.led.off(led)

参数

描述

led

The LED or LEDs to turn off. You can use a single LED like LED1, all LEDs with ALL_LEDS, or a group of LEDs in a tuple like (LED1, LED2). See all available LED names here.

# Turn the LEDs on for 2 seconds.
robot.led.on(ALL_LEDS)
wait(2, SECONDS)
robot.led.off(ALL_LEDS)

# Turn off half the LEDs
robot.led.on(ALL_LEDS)
wait(1, SECONDS)
robot.led.off((LED3, LED4, LED5))