按钮#

介绍#

VEX 123 机器人有四个按钮:移动声音。按钮方法会检查按钮是否被按下。

以下是所有方法的列表:

Getter — 检查按钮是否被按下。

  • get_button — Returns whether a specified button is currently being pressed.

Getter#

get_button#

get_button returns a Boolean that reports whether the specified button is currently being pressed.

  • True — The button is being pressed.

  • False — The button is not being pressed.

Usage:
robot.get_button(button)

范围

描述

button

The button to check:

  • LEFT
  • MOVE
  • RIGHT
  • SOUND

# Drive after the sound button is pressed.
while not robot.get_button(SOUND):
    wait(0.05, SECONDS)
robot.drive(FORWARD)