WS2811 separate leds on channels - FastLED library?

Hello everybody. I obtained a WS2811 based led strip, that has a custom layout, and i'd like to have nice glow and similar effects with it. The problem is that it is not the ordinary 1 led / controller strip.

The strip has alternating red and amber leds. One section has two WS2811 chips, and each channel of the WS2811 controls 3 same coloured neighbouring leds. I will refer to this trio as a pixel.

The R channel of the first WS2811 controls the first amber pixel, the G channel the first red , and the B channel the second amber.

The R channel of the second WS2811 controls the second red pixel, the G channel the third amber, the B channel the third red.

These sections repeat.

Currently i can do the basic things with FastLED library, but i'm looking for a better approach if exists. I'm mainly looking for a nice way to have flowing animation, and pulsing with either only the red, or the amber leds.

Thanks for reading

Can you post a link to the product and post a wiring diagram?

I'm not able to find the led strip as product, nor wiring diagram. possibly it is custom made. The product is a generic LED strip turn signal from aliexpress. The controllers are WS2811, and it is configured as described above.

Take a moment and draw a wiring diagram that compliments your description.

FastLED allows you to address the pixels in many ways. For example, if you wanted to set a brightness of b for each led in your strip in turn, I think you could use code like this:

for (int n=0; n<NUM_LEDS*3; n++) {
  leds[n/3][n%3] = b;
  FastLED.show();
  delay(100);
  leds[n/3][n%3] = 0;
}
1 Like

Hi Paul, thanks for the reply. I came up with an ugly but working solution, wrapping the FastLED CRGB object:

// Set brightness of every red pixel
void red_pixel(int brightness) {
  for ( int i = 0; i < NUM_LEDS; i++) {
    if ( (i % 2) == 0) { // Every "even" WS2811 has red leds on CHG
      leds[i][1] = brightness;
    } else { // Every odd WS2811 has red leds on CHR and CHB
      leds[i][0] = brightness;
      leds[i][2] = brightness;
    }
  }
}

//Set brightness of given index red pixel
void red_pixel(int i, int brightness) {
  switch (i % 3) { // WS2811 Placement on segment (0 or 1)
    case 0:
      // First red pixel is on first chip ch1
      leds[((i / 3) * 2)][1] = brightness;
      break;
    case 1:
      // Second red pixel is on second chip  ch2
      leds[(((i / 3) * 2) + 1)][0] = brightness;
      break;
    default:
      // Third red pixel is on second chip ch3
      leds[(((i / 3) * 2) + 1)][2] = brightness;
      break;
  }
}

#define NUM_PIXEL NUM_LEDS * 3

for (int n=0; n<NUM_PIXEL; n++) {
  red_pixel(i,255);
}

The strip consist of repeating sections, the WS chip of the section and also the channel is not hard to calculate from the index of a particular single color led.

Simplified:

#define NUM_PIXEL NUM_LEDS * 3


//Set brightness of given index red pixel
void red_pixel(int i, int brightness) {
  int p = i * 2 + 1;
  leds[p/3][p%3] = brightness;
}

// Set brightness of every red pixel
void red_pixel(int brightness) {
  for ( int i = 0; i < NUM_PIXEL; i++) {
    red_pixel(i, brightness);
  }
}

for (int n=0; n<NUM_PIXEL; n++) {
  red_pixel(i,255);
}
1 Like

Thank You very much for the help. The simplified version works flawless (althrough i don't understand the maths), here are my wrappers for both colour pixels:


//Set brightness of given index red pixel
void red_pixel(int i, int brightness) {
  int p = i * 2 + 1;
  leds[p / 3][p % 3] = brightness;
}

// Set brightness of every red pixel
void red_pixel(int brightness) {
  for ( int i = 0; i < NUM_PIXEL; i++) {
    red_pixel(i, brightness);
  }
}

//Set brightness of given index amber pixel
void amber_pixel(int i, int brightness) {
  int p = i * 2;
  leds[p / 3][p % 3] = brightness;
}

// Set brightness of every amber pixel
void amber_pixel(int brightness) {
  for ( int i = 0; i < NUM_PIXEL; i++) {
    amber_pixel(i, brightness);
  }
}

//Set brightness of given index combinedpixel
void pixel(int i, int brightness) {
  amber_pixel(i, brightness);
  red_pixel(i, brightness);
}

// Set brightness of every combined pixel
void pixel(int brightness) {
  for ( int i = 0; i < NUM_PIXEL; i++) {
    amber_pixel(i, brightness);
    red_pixel(i, brightness);
  }
}

I've attached a professional schematic of the led strip, maybe it will help others.

I'm not sure what kind of professional would draw a schematic like that. I am now confused and I can't see how the code I gave you can work at all, if the strip is wired like that.

I was just trying to be funny with the "professional schematic". Maybe it is confusing, or misleading, but the led's on the strip are wired exactly like that to each WS2811. They are connected via din dout of course, that is not visible on the picture. And the simplified code You gave me works like a charm, the code paste from my last post can address the amber and red pixels (led cluster on a WS2311 channel) individually on the correct index. Why does Your simple formula work, that is unknown to me also. BTW, im learning KiCad to take my professional schematics to another level :slight_smile:

EDIT:
In my sketch, i use

#define NUM_PIXEL (NUM_LEDS/2)*3

instead of

#define NUM_PIXEL NUM_LEDS*3

Maybe I do get it.

I assume this is a 12V powered strip?

Yes it is, to be exact the OEM control unit supplies 10.5 when VIN is 11.4 from 12V motorcycle battery.

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