class wpilib.Solenoid(*args, **kwargs)[source]

Bases: wpilib.SolenoidBase

Solenoid class for running high voltage Digital Output.

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


Arguments can be supplied as positional or keyword. Acceptable positional argument combinations are:

  • channel
  • moduleNumber, channel

Alternatively, the above names can be used as keyword arguments.

  • moduleNumber (int) – The CAN ID of the PCM the solenoid is attached to
  • channel (int) – The channel on the PCM to control (0..7)

Mark the solenoid as freed.


Read the current value of the solenoid.

Returns:The current value of the solenoid.
Return type:bool
Check if the solenoid is blacklisted.
If a solenoid is shorted, it is added to the blacklist and disabled until power cycle, or until faults are cleared. See clearAllPCMStickyFaults()
Returns:If solenoid is disabled due to short.

Set the value of a solenoid.

Parameters:on (bool) – Turn the solenoid output off or on.