模拟#
介绍#
模拟设备读取来自传统VEX 3引脚模拟传感器的连续电压信号,使V5 Brain能够测量一系列值,而不是像DigitalIn那样测量高或低状态。
例如,传感器包括:
This page uses analog_a as the example Analog device’s name. Replace it with your own configured name as needed.
以下是可用方法列表:
value– Returns the value of the analog device.changed– Registers a function to be called whenever the analog device’s value changes.
构造函数 – 手动初始化和配置模拟设备。
AnalogIn– Create an Analog device.
价值#
value returns the value of the analog device.
Usage:
analog_a.value(units)
范围 |
描述 |
|---|---|
单位 |
Optional. The units to represent the value:
|
已更改#
changed registers a function to be called whenever the analog device’s value changes.
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)
构造函数#
Constructors are used to create Analog objects, which are necessary for configuring an Analog device.
AnalogIn#
AnalogIn creates an Analog device.
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)