Analog#
Introduction#
An Analog device reads continuous voltage signals from legacy VEX 3-pin analog sensors, allowing the V5 Brain to measure values across a range instead of high or low states like with DigitalIn.
Example sensors are:
This page uses analog_a as the example Analog device’s name. Replace it with your own configured name as needed.
Below is a list of available methods:
value– Returns the value of the analog device.changed– Registers a function to be called whenever the analog device’s value changes.
Constructor – Manually initialize and configure an Analog device.
AnalogIn– Create an Analog device.
value#
value returns the value of the analog device.
Usage:
analog_a.value(units)
Parameter |
Description |
|---|---|
units |
Optional. The units to represent the value:
|
changed#
changed registers a function to be called whenever the analog device’s value changes.
Usage:
analog_a.changed(callback, arg)
Parameters |
Description |
|---|---|
|
A previously defined function that executes when the analog device’s value changes. |
|
Optional. A tuple containing arguments to pass to the callback function. See Functions with Parameters for more information. |
def my_function():
brain.screen.print("Changed")
# Call my_function whenever analog_a's value changes
analog_a.changed(my_function)
Constructor#
Constructors are used to create Analog objects, which are necessary for configuring an Analog device.
AnalogIn#
AnalogIn creates an Analog device.
Usage:
AnalogIn(port)
Parameter |
Description |
|---|---|
|
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)