Skip to content
The banana man edited this page Nov 9, 2023 · 7 revisions

LEDs


Note: This wiki page is still WIP and is untested! Do not take anything in this page for fact before it has been tested.


LED Objects can be used with the AddressableLED class in the edu.wpi.first.wpilibj package.
AddressableLED constructor : public AddressableLED(int port)

In order to actually modify the LEDs, you will need to use the AddressableLEDBuffer object found in the same package.
AddressableLEDBuffer constructor : public AddressableLEDBuffer(int length)
Note that length actually refers to the amount of "pixels" in the LED display.

Then, you need to set the length (amount of pixels) of your AddressableLED object using the respective setLength method.

Your code should end up looking something like this:

AddressableLED led = new AddressableLED(0);
AddressableLEDBuffer ledBuffer = new AddressableLEDBuffer(300); // The WS2812B model LED, in this case, has 300 pixels.

led.setLength(ledBuffer.getLength());

LEDs are very cool. 👍👍👍

Clone this wiki locally