edu.wpi.first.wpilibj

## Class DigitalInput

- java.lang.Object
- - edu.wpi.first.wpilibj.SensorBase
  - - edu.wpi.first.wpilibj.InterruptableSensorBase
    - - edu.wpi.first.wpilibj.DigitalSource
      - - edu.wpi.first.wpilibj.DigitalInput

- All Implemented Interfaces:
    LiveWindowSendable, Sendable

      public class DigitalInput
      extends DigitalSource
      implements LiveWindowSendable

  Class to read a digital input. This class will read digital inputs and return the current value on the channel. Other devices such as encoders, gear tooth sensors, etc. that are implemented elsewhere will automatically allocate digital inputs and outputs as required. This class is only for devices like switches etc. that aren't implemented anywhere else.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase

      `InterruptableSensorBase.WaitResult`

  - ### Field Summary

    - ### Fields inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase

      `m_interrupt, m_isSynchronousInterrupt`

    - ### Fields inherited from class edu.wpi.first.wpilibj.SensorBase

      `kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPCMModules, kPDPChannels, kPDPModules, kPwmChannels, kRelayChannels, kSolenoidChannels, kSystemClockTicksPerMicrosecond`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DigitalInput(int channel)` Create an instance of a Digital Input class.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `free()` Frees the resources for this output.
    `boolean` | `get()` Get the value from a digital input channel.
    `int` | `getAnalogTriggerTypeForRouting()` Get the analog trigger type.
    `int` | `getChannel()` Get the channel of the digital input.
    `int` | `getPortHandleForRouting()` Get the HAL Port Handle.
    `java.lang.String` | `getSmartDashboardType()` The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
    `void` | `initTable(NetworkTable subtable)` Initializes a table for this `Sendable` object.
    `boolean` | `isAnalogTrigger()` Is this an analog trigger.
    `void` | `startLiveWindowMode()` Start having this sendable object automatically respond to value changes reflect the value on the table.
    `void` | `stopLiveWindowMode()` Stop having this sendable object automatically respond to value changes.
    `void` | `updateTable()` Update the table for this sendable object with the latest values.

    - ### Methods inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase

      `allocateInterrupts, cancelInterrupts, disableInterrupts, enableInterrupts, readFallingTimestamp, readRisingTimestamp, requestInterrupts, requestInterrupts, setUpSourceEdge, waitForInterrupt, waitForInterrupt`

    - ### Methods inherited from class edu.wpi.first.wpilibj.SensorBase

      `checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPDPModule, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DigitalInput

          public DigitalInput(int channel)

      Create an instance of a Digital Input class. Creates a digital input given a channel.
      Parameters:
        `channel` - the DIO channel for the digital input 0-9 are on-board, 10-25 are on the MXP

  - ### Method Detail

    - #### free

          public void free()

      Frees the resources for this output.
      Overrides:
        `free` in class `SensorBase`

    - #### get

          public boolean get()

      Get the value from a digital input channel. Retrieve the value of a single digital input channel from the FPGA.
      Returns:
        the status of the digital input

    - #### getChannel

          public int getChannel()

      Get the channel of the digital input.
      Specified by:
        `getChannel` in class `DigitalSource`
      Returns:
        The GPIO channel number that this object represents.

    - #### getAnalogTriggerTypeForRouting

          public int getAnalogTriggerTypeForRouting()

      Get the analog trigger type.
      Specified by:
        `getAnalogTriggerTypeForRouting` in class `InterruptableSensorBase`
      Returns:
        false

    - #### isAnalogTrigger

          public boolean isAnalogTrigger()

      Is this an analog trigger.
      Specified by:
        `isAnalogTrigger` in class `DigitalSource`
      Returns:
        true if this is an analog trigger

    - #### getPortHandleForRouting

          public int getPortHandleForRouting()

      Get the HAL Port Handle.
      Specified by:
        `getPortHandleForRouting` in class `InterruptableSensorBase`
      Returns:
        The HAL Handle to the specified source.

    - #### getSmartDashboardType

          public java.lang.String getSmartDashboardType()

      Description copied from interface: `Sendable`
      The string representation of the named data type that will be used by the smart dashboard for this `Sendable`.
      Specified by:
        `getSmartDashboardType` in interface `Sendable`
      Returns:
        The type of this `Sendable`.

    - #### initTable

          public void initTable(NetworkTable subtable)

      Description copied from interface: `Sendable`
      Initializes a table for this `Sendable` object.
      Specified by:
        `initTable` in interface `Sendable`
      Parameters:
        `subtable` - The table to put the values in.

    - #### updateTable

          public void updateTable()

      Description copied from interface: `LiveWindowSendable`
      Update the table for this sendable object with the latest values.
      Specified by:
        `updateTable` in interface `LiveWindowSendable`

    - #### startLiveWindowMode

          public void startLiveWindowMode()

      Description copied from interface: `LiveWindowSendable`
      Start having this sendable object automatically respond to value changes reflect the value on the table.
      Specified by:
        `startLiveWindowMode` in interface `LiveWindowSendable`

    - #### stopLiveWindowMode

          public void stopLiveWindowMode()

      Description copied from interface: `LiveWindowSendable`
      Stop having this sendable object automatically respond to value changes.
      Specified by:
        `stopLiveWindowMode` in interface `LiveWindowSendable`