How to make leds go through a rainbow effect in auto and teleop

We want to make a rainbow effect with are LEDs in auto but also we want to make it attached to a button to it for teleop for when we get a triple charge station

If you share your code (preferably as a link to github or similar), we can provide more specific instructions.

But generally, you just need to have the code that generates the rainbow pattern somewhere thats reusable. This could be as simple as a function that you call from 2 different places.

Or if youre using the command-based pattern, i would do it as a command. Then add that command to your auto routine, and trigger it through a button press as well, same as any other command. The command would then call a method in a LED subsystem to generate/initiate the pattern.

This thread from last year covers some led usage and links to some code we used.

We don’t have anything on our code for it but I can still send it if you like to

Ah okay, I assumed you already had some level of functional LEDs and were just trying to add to it.

In that case, my general suggestions combined with the docs for AddressableLED and thread linked by @Bmongar should get you there.

Here is our LED commands: frc_slice/src/main/java/frc/robot/commands/LEDs at Pre-Pembroke-Code · tkruger/frc_slice · GitHub

And our LED subsystem: frc_slice/LEDs.java at Pre-Pembroke-Code · tkruger/frc_slice · GitHub

We are using 12v addressable LEDs powered by the VRM with data plugged into a PWM port

1 Like