Constructor for LED lights

We’re trying to make these LED lights change colors when clicking a button on the controller. We need a constructor for what we need to put in our string in the robot container for our button so the command is called when the button is pressed.

Not enough info to help.

What LEDs? How are they connected? Where’s your code? What have you already tried? How isn’t it working?

1 Like

Read the WPILib documentation, it includes how to use the built-in AdressableLED class.

Is this the documentation you are referring to? If so, we have already tried to reference this, but it didn’t provide much help for the constructor we need and the command we have.

At which part are you getting stuck?

I would add the AddressableLED object to a subsystem and then (indirectly) change the AddressableLEDBuffer through a command. Does that help you any further?

We have the PHOPOLLO Led Strip Light, 5m. To connect the LED’s, we’re using a 4pin LED Connector to plug it in to the power distribution board and a PWM extension cable to connect the signal and power wire on the 4pin LED connector. We tried making a constructor for our command too, but it… ’

This is the code we have so far too.

I don’t see any of the example code in your current code.

If you’re going to write something custom, we can’t help you all that much. I would suggest putting all the example code into your robot code as is, and see if your strip works. You don’t have an AddressableLED object anywhere that I can see there.

Here’s an example LED subsystem from our code a couple of years ago. Should still work.

I’m assuming you intended to include a link?

1 Like

There are many products from this brand listed on Amazon. If you can provide a specific link, we can help you better.

I think I’m starting to see a possible problem here. The WPILib AddressableLED support is designed to control WS2812 LED strips - WS2812B are the most common type of these. Most WS2812 strips run on 5V and are a 3-wire connection (5V, ground, signal) where the signal comes from one of the Rio’s PWM outputs. Since you are connecting directly to the PDP, you seem to have a 12V connection. One common form of 12V LED strip has a 4-wire connection where there is one shared connection and then individual signals for red, green, blue; this type of strip shows one color along its whole length, as opposed to the individually-addressable LEDs of the WS2812 type. If this is what you have, you won’t be able to drive it directly from the Rio (at least not with AddressableLED).

A link to your repository would be helpful. Your screenshot shows what appears to be a constructor for an LEDStrip subsystem that we can’t see the code for, so we don’t have any idea what it’s doing.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.