Solenoid

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

Bases: wpilib.SolenoidBase

Solenoid class for running high voltage Digital Output.

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

Constructor.

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.

Parameters:
  • moduleNumber (int) – The CAN ID of the PCM the solenoid is attached to
  • channel (int) – The channel on the PCM to control (0..7)
free()[source]

Mark the solenoid as freed.

get()[source]

Read the current value of the solenoid.

Returns:True if the solenoid output is on or false if the solenoid output is off.
Return type:bool
initSendable(builder)[source]
isBlackListed()[source]
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 SolenoidBase.clearAllPCMStickyFaults()
Returns:If solenoid is disabled due to short.
set(on)[source]

Set the value of a solenoid.

Parameters:on (bool) – True will turn the solenoid output on. False will turn the solenoid output off.
setPulseDuration(durationSeconds)[source]

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:durationSeconds – The duration of the pulse, from 0.01 to 2.55 seconds.
solenoidHandle
startPulse()[source]

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

see setPulseDuration()