模拟#
介绍#
模拟设备读取来自传统VEX 3引脚模拟传感器的连续电压信号,使V5 Brain能够测量一系列值,而不是像DigitalIn那样测量高或低状态。
例如,传感器包括:
本页面使用 analog_a 作为模拟设备的示例名称。请根据需要将其替换为您自己配置的名称。
以下是可用方法列表:
构造函数 – 手动初始化和配置模拟设备。
AnalogIn– 创建一个模拟设备。
价值#
value 返回表示来自不同传感器的电压信号的模拟设备的值。
Usage:
analog_a.value(units)
范围 |
描述 |
|---|---|
|
Optional. The units to represent the value:
|
已更改#
changed 注册一个函数,当模拟设备的值发生变化时,该函数将被调用。
Usage:
analog_a.changed(callback, arg)
参数 |
描述 |
|---|---|
|
先前定义的 函数,当模拟设备的值发生变化时执行。 |
|
def my_function():
brain.screen.print("Changed")
# Call my_function whenever analog_a's value changes
analog_a.changed(my_function)
构造函数#
构造函数用于创建 Analog 对象,这些对象是配置模拟设备所必需的。
AnalogIn#
AnalogIn 创建一个模拟设备。
Usage:
AnalogIn(port)
范围 |
描述 |
|---|---|
|
The 3-Wire Port that the analog device is connected to:
|
# Create an analog device in Port A
analog_a = AnalogIn(brain.three_wire_port.a)