Class AnalogInput

java.lang.Object
org.wpilib.hardware.discrete.AnalogInput
All Implemented Interfaces:
AutoCloseable, TelemetryLoggable

public class AnalogInput extends Object implements TelemetryLoggable, AutoCloseable
Analog channel class.

Each analog channel is read from hardware as a 12-bit number representing 0V to 3.3V.

  • Constructor Details

    • AnalogInput

      public AnalogInput(int channel)
      Construct an analog channel.
      Parameters:
      channel - The SmartIO channel for the analog input.
  • Method Details

    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • getValue

      public int getValue()
      Get a sample straight from this channel. The sample is a 12-bit value representing the 0V to 3.3V range of the A/D converter. The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units.
      Returns:
      A sample straight from this channel.
    • getVoltage

      public double getVoltage()
      Get a scaled sample straight from this channel. The value is scaled to units of Volts.
      Returns:
      A scaled sample straight from this channel.
    • getChannel

      public int getChannel()
      Get the channel number.
      Returns:
      The channel number.
    • setSimDevice

      public void setSimDevice(SimDevice device)
      Indicates this input is used by a simulated device.
      Parameters:
      device - simulated device handle
    • logTo

      public void logTo(TelemetryTable table)
      Description copied from interface: TelemetryLoggable
      Logs the object to a TelemetryTable.
      Specified by:
      logTo in interface TelemetryLoggable
      Parameters:
      table - telemetry table
    • getTelemetryType

      public String getTelemetryType()
      Description copied from interface: TelemetryLoggable
      Gets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.
      Specified by:
      getTelemetryType in interface TelemetryLoggable
      Returns:
      Table type