Class AnalogInput

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

public class AnalogInput extends Object implements Sendable, 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
    • initSendable

      public void initSendable(SendableBuilder builder)
      Description copied from interface: Sendable
      Initializes this Sendable object.
      Specified by:
      initSendable in interface Sendable
      Parameters:
      builder - sendable builder