Solenoid

class wpilib.Solenoid(*args, **kwargs)

Bases: wpiutil._wpiutil.Sendable

Solenoid class for running high voltage Digital Output on a pneumatics module.

The Solenoid class is typically used for pneumatics solenoids, but could be used for any device within the current spec of the module.

Overloaded function.

  1. __init__(self: wpilib._wpilib.Solenoid, module: int, moduleType: wpilib._wpilib.PneumaticsModuleType, channel: int) -> None

Constructs a solenoid for a specified module and type.

Parameters
  • module – The module ID to use.

  • moduleType – The module type to use.

  • channel – The channel the solenoid is on.

  1. __init__(self: wpilib._wpilib.Solenoid, moduleType: wpilib._wpilib.PneumaticsModuleType, channel: int) -> None

Constructs a solenoid for a default module and specified type.

Parameters
  • moduleType – The module type to use.

  • channel – The channel the solenoid is on.

get() bool

Read the current value of the solenoid.

Returns

The current value of the solenoid.

getChannel() int

Get the channel this solenoid is connected to.

initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
isDisabled() bool

Check if solenoid is Disabled.

If a solenoid is shorted, it is added to the DisabledList and disabled until power cycle, or until faults are cleared.

@see ClearAllPCMStickyFaults()

Returns

If solenoid is disabled due to short.

set(on: bool) None

Set the value of a solenoid.

Parameters

on – Turn the solenoid output off or on.

setPulseDuration(duration: seconds) None

Set the pulse duration in the PCM. This is used in conjunction with the startPulse method to allow the PCM to control the timing of a pulse. The timing can be controlled in 0.01 second increments.

@see startPulse()

Parameters

duration – The duration of the pulse, from 0.01 to 2.55 seconds.

startPulse() None

%Trigger the PCM to generate a pulse of the duration set in setPulseDuration.

@see setPulseDuration()

toggle() None

Toggle the value of the solenoid.

If the solenoid is set to on, it’ll be turned off. If the solenoid is set to off, it’ll be turned on.