AddressableLED

class wpilib.AddressableLED(port: int)

Bases: pybind11_object

A class for driving addressable LEDs, such as WS2812Bs and NeoPixels.

By default, the timing supports WS2812B LEDs, but is configurable using SetBitTiming()

Only 1 LED driver is currently supported by the roboRIO. However, multiple LED strips can be connected in series and controlled from the single driver.

Constructs a new driver for a specific port.

Parameters:

port – the output port to use (Must be a PWM header)

class LEDData(*args, **kwargs)

Bases: AddressableLEDData

Overloaded function.

  1. __init__(self: wpilib._wpilib.AddressableLED.LEDData) -> None

  2. __init__(self: wpilib._wpilib.AddressableLED.LEDData, r: int, g: int, b: int) -> None

setHSV(h: int, s: int, v: int) None

A helper method to set all values of the LED.

Parameters:
  • h – the h value [0-180]

  • s – the s value [0-255]

  • v – the v value [0-255]

setLED(*args, **kwargs)

Overloaded function.

  1. setLED(self: wpilib._wpilib.AddressableLED.LEDData, color: wpilib._wpilib.Color) -> None

  2. setLED(self: wpilib._wpilib.AddressableLED.LEDData, color: wpilib._wpilib.Color8Bit) -> None

setRGB(r: int, g: int, b: int) None

A helper method to set all values of the LED.

Parameters:
  • r – the r value [0-255]

  • g – the g value [0-255]

  • b – the b value [0-255]

setBitTiming(highTime0: wpimath.units.nanoseconds, lowTime0: wpimath.units.nanoseconds, highTime1: wpimath.units.nanoseconds, lowTime1: wpimath.units.nanoseconds) None

Sets the bit timing.

By default, the driver is set up to drive WS2812Bs, so nothing needs to be set for those.

Parameters:
  • highTime0 – high time for 0 bit (default 400ns)

  • lowTime0 – low time for 0 bit (default 900ns)

  • highTime1 – high time for 1 bit (default 900ns)

  • lowTime1 – low time for 1 bit (default 600ns)

setData(ledData: List[wpilib._wpilib.AddressableLED.LEDData]) None

Sets the led output data.

If the output is enabled, this will start writing the next data cycle. It is safe to call, even while output is enabled.

Parameters:

ledData – the buffer to write

setLength(length: int) None

Sets the length of the LED strip.

Calling this is an expensive call, so its best to call it once, then just update data.

The max length is 5460 LEDs.

Parameters:

length – the strip length

setSyncTime(syncTime: wpimath.units.microseconds) None

Sets the sync time.

The sync time is the time to hold output so LEDs enable. Default set for WS2812B.

Parameters:

syncTime – the sync time (default 280us)

start() None

Starts the output.

The output writes continuously.

stop() None

Stops the output.