Package edu.wpi.first.wpilibj
Class DigitalInput
java.lang.Object
edu.wpi.first.wpilibj.DigitalInput
- All Implemented Interfaces:
Sendable
,AutoCloseable
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
boolean
get()
Get the value from a digital input channel.int
Get the channel of the digital input.void
initSendable
(SendableBuilder builder) Initializes thisSendable
object.void
setSimDevice
(SimDevice device) Indicates this input is used by a simulated device.
-
Constructor Details
-
DigitalInput
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 Details
-
close
- Specified by:
close
in interfaceAutoCloseable
-
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
Get the channel of the digital input.- Returns:
- The GPIO channel number that this object represents.
-
setSimDevice
Indicates this input is used by a simulated device.- Parameters:
device
- simulated device handle
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-