DigitalInput

class wpilib.DigitalInput(channel: SupportsInt | SupportsIndex)

Bases: Sendable

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.

Create an instance of a Digital Input class.

Creates a digital input given a channel.

Parameters:

channel – The SmartIO channel

get() bool

Get the value from a digital input channel.

Retrieve the value of a single digital input channel from the FPGA.

getChannel() int
Returns:

The GPIO channel number that this object represents.

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
setSimDevice(device: SupportsInt | SupportsIndex) None

Indicates this input is used by a simulated device.

Parameters:

device – simulated device handle