脑#
介绍#
VEX IQ(第二代)脑波感应类别提供了与大脑按钮和连接的电池进行交互的方法。
本页面使用 brain 作为示例大脑名称。您可以根据需要将其替换为您自己配置的名称。
以下是所有方法的列表:
操作——与VEX IQ(第二代)按钮进行交互。
获取器 — 返回按钮和电池的数据。
构造函数——手动初始化大脑。
brain— 创建一个大脑。
行动#
pressed#
pressed 注册一个函数,当大脑上的特定按钮被按下时,该函数将被调用。此方法必须在特定的按钮对象上调用,例如 buttonCheck —(请参阅下面的按钮对象完整列表)。
用法:
三个可用按钮对象之一可与此方法一起使用,如下所示:
按钮 |
命令 |
|---|---|
|
|
|
|
|
|
参数 |
描述 |
|---|---|
|
先前定义的在按下指定按钮时执行的 函数。 |
|
# Turn in a circle when the left button
# is pressed
def button_pressed():
drivetrain.turn_for(RIGHT, 360, DEGREES)
brain.buttonLeft.pressed(button_pressed)
released#
released 注册一个函数,当 Brain 上的特定按钮被释放时,该函数将被调用。此方法必须在特定的按钮对象上调用,例如 buttonCheck —(请参阅下面的按钮对象完整列表)。
用法:
三个可用按钮对象之一可与此方法一起使用,如下所示:
按钮 |
命令 |
|---|---|
|
|
|
|
|
|
参数 |
描述 |
|---|---|
|
先前定义的在释放指定按钮时执行的 函数。 |
|
# Turn in a circle when the left button
# is released
def button_released():
drivetrain.turn_for(LEFT, 360, DEGREES)
brain.buttonLeft.released(button_released)
吸气剂#
pressing#
pressing 返回一个布尔值,指示大脑上的特定按钮当前是否被按下。此方法必须在特定的按钮对象上调用,例如 buttonCheck (请参阅下面的完整按钮对象列表)。
True— 指定的按钮正在被按下。False— 指定的按钮未被按下。
用法:
三个可用按钮对象之一可与此方法一起使用,如下所示:
按钮 |
命令 |
|---|---|
|
|
|
|
|
|
参数 |
描述 |
|---|---|
该方法没有参数。 |
# Turn when the check button is pressed
while True:
if brain.buttonCheck.pressing():
drivetrain.turn(RIGHT)
else:
drivetrain.stop()
capacity#
capacity 返回剩余电池电量,以百分比表示,范围从 0% 到 100%。
Usage:
brain.battery.capacity()
参数 |
描述 |
|---|---|
该方法没有参数。 |
# Display the current battery capacity
brain.screen.print(brain.battery.capacity())
voltage#
Voltage is the electrical pressure supplied to the battery. voltage returns the voltage of the battery as a decimal (float), which can help you check whether the battery is charged enough for the robot to run reliably, ranging from 7.0 to 8.0 Volts.
Usage:
brain.battery.voltage(units)
参数 |
描述 |
|---|---|
|
可选。电压单位: |
# Display the current voltage of the battery
brain.screen.print(brain.battery.voltage())
current#
电流表示机器人从电池消耗的电量。0 电流 current ,以十进制数 (float) 表示,这可以帮助您了解机器人的工作强度或电机是否可能承受额外负载,范围从 0.0 到 15.0 安培。
Usage:
brain.battery.current()
参数 |
描述 |
|---|---|
该方法没有参数。 |
# Display the current of the battery
brain.screen.print(brain.battery.current())
构造函数#
Brain#
Brain 创建一个 brain 类的对象。
Usage:
brain = Brain()
参数 |
描述 |
|---|---|
该方法没有参数。 |
brain = Brain()
# Turn when the check button is pressed
while True:
if brain.buttonCheck.pressing():
drivetrain.turn(RIGHT)
else:
drivetrain.stop()