For this off-season, my team is using two LED strips on opposite sides of the robot connected together to one port. When we try to activate the LEDs, it only activates the first LED that we activate (using the following command).
public void setLEDColor(Color color, int index) {
LEDStripConstants.LED_BUFFER.setLED(index + indexOffset, color);
LED.setData(LEDStripConstants.LED_BUFFER);
}
When I run this command twice with a different index, it only turns on the first LED that I tried to set, but it runs through both commands. When I use the following command, it turns on all the LEDs, but if I run it twice, it only turns on the first LEDs that I’m trying to set.
public void setLEDColors(Color color, int startIndex, int endIndex) {
for (int i = 0; i < endIndex - startIndex; i++) {
LEDStripConstants.LED_BUFFER.setLED(startIndex + indexOffset + i, color);
}
LED.setData(LEDStripConstants.LED_BUFFER);
}
Splitting LED strips from the same port can cause some weird issues with signal reflections, especially if the wires leading from the data port are not the same length. I would recommend turning your two strips into one strip that’s double the length. Alternatively, place 1 led super close to the rio and split the strip after the 1st LED (the WS2812B regenerates a much cleaner signal that what arduinos/rios produce).
So you’re saying it’s probably not a code problem? Additionally, can you elaborate on your second solution? I’m not 100% confident with my electronics capabilities
Can you be more specific on that? You can’t put two leds in one port, you connect the two leds stripes in series and they would become one stripe with double the length. I know this is a bit confusing but it’s how it works.
You can definitely connect 2 data ports of ws2812 strips to the same IO pin on an Arduino/Rio and it will mirror the strips. But you can have some strange side effects.
If you connect them in series, you should treat them as one LED stripe with 2x the original length. The stripe connected to your robotRIO can be controlled normally. But for the stripe connected to that stripe, you would have to map the address from i to i+n where n is the length.
addressible led strips are usually directional, its possible you have it plugged in backwards. try looking for an indicator of direction on the strip (the leds our team uses has little arrows on them), or try lookimg at the user manual for your leds
Can you post a link to your full repo (or a full sample code project)?
I’m happy to run it on the Rio and ARGBs that I have here (or someone on CD might be able to spot the problem from the full code that isn’t visible in the snippet).
Move the setData call on line 78 out of the loop (down past the close-brace).
Add a setData call to the end of staticColor (line 71-and-a-half).
Change the <= to < on lines 70 and 75 (and, IMO, not on 101 but then you need to be cautious about how you compute end index).
Edit to add:
Actually, that’s still not quite enough. (It was working while I tested with the rainbow and blink, but not with the getStaticColorCommand calls.)
Hopefully, that got you to at least “it’s in the code” (because Rainbow and Blink work), but I have to do some day job now.