AnalogPotentiometer

class wpilib.AnalogPotentiometer(*args, **kwargs)

Bases: Sendable

Class for reading analog potentiometers. Analog potentiometers read in an analog voltage that corresponds to a position. The position is in whichever units you choose, by way of the scaling and offset constants passed to the constructor.

Overloaded function.

  1. __init__(self: wpilib._wpilib.AnalogPotentiometer, channel: int, fullRange: float = 1.0, offset: float = 0.0) -> None

Construct an Analog Potentiometer object from a channel number.

Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0 degrees and the offset is -135.0 since the halfway point after scaling is 135 degrees.

This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

Parameters:
  • channel – The Analog Input channel number on the roboRIO the potentiometer is plugged into. 0-3 are on-board and 4-7 are on the MXP port.

  • fullRange – The value (in desired units) representing the full 0-5V range of the input.

  • offset – The value (in desired units) representing the angular output at 0V.

  1. __init__(self: wpilib._wpilib.AnalogPotentiometer, input: wpilib._wpilib.AnalogInput, fullRange: float = 1.0, offset: float = 0.0) -> None

Construct an Analog Potentiometer object from an existing Analog Input pointer.

Use the fullRange and offset values so that the output produces meaningful values. I.E: you have a 270 degree potentiometer and you want the output to be degrees with the halfway point as 0 degrees. The fullRange value is 270.0 degrees and the offset is -135.0 since the halfway point after scaling is 135 degrees.

This will calculate the result from the fullRange times the fraction of the supply voltage, plus the offset.

Parameters:
  • input – The existing Analog Input pointer

  • fullRange – The value (in desired units) representing the full 0-5V range of the input.

  • offset – The value (in desired units) representing the angular output at 0V.

get() float

Get the current reading of the potentiometer.

Returns:

The current position of the potentiometer (in the units used for fullRange and offset).

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None