DigitalOutput

class wpilib.DigitalOutput(channel)[source]

Bases: wpilib.DigitalSource

Writes to a digital output

Other devices that are implemented elsewhere will automatically allocate digital inputs and outputs as required.

Create an instance of a digital output.

Parameters:channel – the DIO channel for the digital output. 0-9 are on-board, 10-25 are on the MXP
disablePWM()[source]

Change this line from a PWM output back to a static Digital Output line.

Free up one of the 6 DO PWM generator resources that were in use.

enablePWM(initialDutyCycle)[source]

Enable a PWM Output on this line.

Allocate one of the 6 DO PWM generator resources.

Supply the initial duty-cycle to output so as to avoid a glitch when first starting.

The resolution of the duty cycle is 8-bit for low frequencies (1kHz or less) but is reduced the higher the frequency of the PWM signal is.

Parameters:initialDutyCycle (float) – The duty-cycle to start generating. [0..1]
free()[source]

Free the resources associated with a digital output.

getChannel()[source]
Returns:The GPIO channel number that this object represents.
isPulsing()[source]

Determine if the pulse is still going. Determine if a previously started pulse is still going.

Returns:True if pulsing
Return type:bool
pulse(channel, pulseLength)[source]

Generate a single pulse. Write a pulse to the specified digital output channel. There can only be a single pulse going at any time.

Parameters:
  • channel – The channel to pulse.
  • pulseLength (float) – The length of the pulse.
pwmGenerator[source]
set(value)[source]

Set the value of a digital output.

Parameters:value (bool) – True is on, off is False
setPWMRate(rate)[source]

Change the PWM frequency of the PWM output on a Digital Output line.

The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic.

There is only one PWM frequency for all channnels.

Parameters:rate (float) – The frequency to output all digital output PWM signals.
updateDutyCycle(dutyCycle)[source]

Change the duty-cycle that is being generated on the line.

The resolution of the duty cycle is 8-bit for low frequencies (1kHz or less) but is reduced the higher the frequency of the PWM signal is.

Parameters:dutyCycle (float) – The duty-cycle to change to. [0..1]