按鈕#

介紹#

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)