-
Notifications
You must be signed in to change notification settings - Fork 6
LEDs
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)
Length refers to the amount of LEDs, or "pixels" on the LED strip.
Then, you need to set the length (amount of LEDs) of your AddressableLED object using the respective setLength method. Note that you should never ever call getLength
And finally, you need to set the data of the LED using AddressableLED#setData(buffer), and initiate it with AddressableLED#start.
// The following code is a snippet from the LED subsystem I wrote.
private AddressableLED led;
private AddressableLEDBuffer buffer;
private static final int port = 0; // The PWM port of the LED strip
private int length; // How many leds, or "pixels" are on the strip
public LEDSubsystem(int pixels) {
this.length = pixels;
buffer = new AddressableLEDBuffer(pixels);
led = new AddressableLED(port);
led.setLength(pixels);
led.setData(buffer);
led.start();
led.setData(buffer);
}Actually using the LEDs is very easy. The AddressableLEDBuffer class has various methods to make your life much easier.
NOTE: You need to update the
AddressableLED's data after making changes to the buffer!
There are two different methods that you can use to set specific pixels:
- `AddressableLEDBuffer#setRGB`
- `AddressableLEDBuffer#setHSV`
\> You can also loop though every pixel using a for loop to set all pixels.
\> After setting the buffer's pixels, you need to update it using `AddressableLED#setData(buffer)`. It is recommended to do this after you are finished changing pixels rather than every time you change a pixel.
LEDs are very cool. 👍👍👍
This is an officially licensed product of Team 4026. Decatur Robotics 2024 is not sponsored by any other Team, and is not responsible for any damages caused by using this product or trusting the programming team, which is by far the least most trustworthy team(Shadow owen money gang, we love coding the robot). By using this product, you are consenting to your information, and thus your identity to be stolen and first-born child taken.
- Editing Documentation & Markdown Syntax
- Code Team to-do List
- Code Standards
- Common Library Structure
- Interfaces
- General Setup
- Branching System
- How to Create Pull Requests
- How to Switch Branches
- Code Reviews
- Reverting Commits
- Singleton Pattern
- Software Installations
- Necessary IntelliJ Plugins
- Vendordeps
- Setting Up New Projects
- Autoformatter Set Up
- Showbot Requirements
- Autonomous
- Calling a Command Based on a Button Press
- CAN
- Clearing Sticky Faults
- Current Limits
- PID Config and Usage
- Robot.java, TeleopInit, DisabledInit
- RoboRio Ports
- SetDefaultCommand
- Wait for Time
- SlewRateLimiter
- LEDs
- InstantCommand
- PhotonVision
- Apriltags
- Camera Display on Shuffleboard
- Object Detection
- Raspberry Pi
- Network Tables
- List of Network Tables (2023)
Up to date as of SJ2, end of 2023 season