按钮#

介绍#

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

以下是所有方法的列表:

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

  • get_button — 返回指定的按钮当前是否被按下。

Getter#

get_button#

get_button 返回一个 Boolean,报告指定的按钮当前是否被按下。

  • True — 按钮被按下。

  • False ​​— 按钮未被按下。

Usage:
robot.get_button(button)

范围

描述

button

要检查的按钮:

  • LEFT
  • MOVE
  • RIGHT
  • SOUND

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