AddressableLED

class wpilib.AddressableLED(self: wpilib.AddressableLED, port: int) → None

Bases: wpilib.ErrorBase

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

Only 1 LED driver is currently supported by the roboRIO.

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: pybind11_builtins.pybind11_object

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(self: wpilib._wpilib.AddressableLED.LEDData, 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(self: wpilib._wpilib.AddressableLED.LEDData, 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(self: wpilib.AddressableLED, lowTime0: nanoseconds, highTime0: nanoseconds, lowTime1: nanoseconds, highTime1: nanoseconds) → None

Sets the bit timing.

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

Parameters
  • lowTime0 – low time for 0 bit

  • highTime0 – high time for 0 bit

  • lowTime1 – low time for 1 bit

  • highTime1 – high time for 1 bit

setData(self: wpilib.AddressableLED, 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(self: wpilib.AddressableLED, 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(self: wpilib.AddressableLED, syncTime: microseconds) → None

Sets the sync time.

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

Parameters

syncTimeMicroSeconds – the sync time

start(self: wpilib.AddressableLED) → None

Starts the output.

The output writes continuously.

stop(self: wpilib.AddressableLED) → None

Stops the output.