Potentiometer#
Introduction#
The Potentiometer is an analog sensor that measures the angular position of a rotating shaft. It outputs a voltage proportional to its position.
Depending on the Potentiometer version, the amount of rotation it can detect varies:
Potentiometer – Up to 250 degrees
Potentiometer V2 – 330 degrees (Continuous)
|
|
|---|---|
Potentiometer |
Potentiometer V2 |
This page uses potentiometer_a as the example Potentiometer name. Replace it with your own configured name as needed.
Below is a list of available methods:
angle– Reports the angular position of the Potentiometer in degrees or as a percent.changed– Registers a function to be called whenever the Potentiometer’s value changes.
Constructors – Manually initialize a Potentiometer or Potentiometer V2.
PotentiometerV2– Create a Potentiometer V2.Potentiometer– Create a Potentiometer.
angle#
angle returns the angular position of the Potentiometer.
Usage:
potentiometer_a.angle(units)
Parameter |
Description |
|---|---|
units |
The unit of measurement:
|
changed#
changed registers a function to be called whenever the Potentiometer’s value changes.
Usage:
changed(callback, arg)
Parameters |
Description |
|---|---|
|
A previously defined function that executes when the Potentiometer’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("Value changed!")
# Call my_function whenever potentiometer_a's angle changes
potentiometer_a.changed(my_function)
Constructors#
Constructors are used to manually create PotentiometerV2 and Potentiometer objects, which are necessary for configuring Potentiometers outside of VEXcode.
PotentiometerV2#
PotentiometerV2 creates a V5 Potentiometer V2.
Usage:
PotentiometerV2(port)
Parameter |
Description |
|---|---|
|
The 3-Wire Port that the Potentiometer V2 is connected to:
|
# Create a Potentiometer V2 in Port A
potentiometer_a = PotentiometerV2(brain.three_wire_port.a)
Potentiometer#
Potentiometer creates a Potentiometer.
Usage:
Potentiometer(port)
Parameter |
Description |
|---|---|
|
The 3-Wire Port that the Potentiometer is connected to:
|
# Create a Potentiometer in Port A
potentiometer_a = Potentiometer(brain.three_wire_port.a)

