Skip to content

Analog Inputs

NextAnalogInput is a wrapper around an analog input that gives you convenient access to different readings.

It inherits from AnalogFeedback, so any NextAnalogInput can also be passed directly as the feedback source for a feedback servo.

// By Lynx Module and channel, recommended
val input = NextAnalogInput(RobotController.controlHub, 0)
// Using your configuration name
val input = NextAnalogInput("armEncoder")

Both constructors accept two optional parameters:

Parameter Type Default Description
customTransformation (Double) -> Double Value Unchanged An optional transformation applied to the normalized voltage ratio.
maxVoltage Voltage 3.3.volts The voltage that corresponds to a normalized value of 1.0.

Voltage this is the raw, untransformed voltage currently read from the analog input.

val voltage = input.rawVoltage

Double the normalized reading, starting as rawVoltage then divided by your maxVoltage and passed through your customTransformation.

val normalized = input.value