Single color WS2811 strip, flickering on lower brightness?

I am pretty sure I have a WS2811 12V LED strip that is using 2835 single color leds. Sadly I have no way to be completely sure, as described in a post here:
https://www.reddit.com/r/FastLED/comments/1p5mb5k/is_fastled_good_for_powering_on_and_off_repeatedly/

There are two separate LED strips in the housing, each with a separate data wire. When I set NUM_LEDS to 1 this is the result, keep in mind that this is two separate LED-strips receiving the same command, so in effect it is 2 that it lit up below.

Setting NUM_LEDS to 9 fills both LED-strips completely.

At the moment this is the code I am using:

#include <FastLED.h>
#define LED_PIN 16
#define NUM_LEDS 9

CRGB leds[NUM_LEDS];

void setup() {
FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(140);
}

void loop() {
for (int i = 0; i < 5; i++) leds[i] = CRGB::White;
leds[5] = CRGB::White; leds[5].nscale8(220);
leds[6] = CRGB::White; leds[6].nscale8(210);
leds[7] = CRGB::White; leds[7].nscale8(180);
leds[8] = CRGB::White; leds[8].nscale8(130);
FastLED.show();
}

I set it up this way to dim the outer edges a bit as they are closer to the housing, this looks more even.

Now to the weird stuff. If I plug in the LED strip with only power, nothing happens as expected. But if I plug in the data wires the LED strip will light up instantly when it powers on, but after a few seconds it will dim down to my setting. I cannot understand this, as the first signals I send to the LED strips is brightness? Shown here: Imgur: The magic of the Internet

I did try code without the loop part, and doing everything in setup, as the only thing I want is that when it receives power it should light up to my specified settings, nothing else.
But this resulted in the LED's not lighting up after loosing power, they only lit up when I uploaded the code with it powered on.

How do I solve the flickering issue I have? Can I be sure it is WS2811, or can this be causes by some compability issue, and me using the wrong library?

Here's the flickering I am talking about: Imgur: The magic of the Internet

You’re not doing anything wrong this is normal WS2811 behavior.
When the strip gets power but no valid data yet, the data line floats for a moment and the WS2811 interprets the noise as a frame. That’s why the LEDs turn on before your code runs.

When your MCU finally boots and FastLED sends the first real frame, the LEDs “jump” to your intended brightness, which looks like flicker.

To fix it, you need to pull the data line LOW during boot so the WS2811 sees a stable 0 instead of noise. The easiest fix is:

pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
delay(50);
FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.show(); // send clean frame immediately

This keeps the LEDs off until FastLED takes over.

And yes from what you describe, it behaves exactly like a WS2811 strip.

Fantastic, I will try that, will this work good on the Arduino I am using ( this one Mega 2560 PRO (Embed) CH340G/ATmega2560-16AU - Hardware, Software, Gadgets & Future Tech News )?

The jump from full brightness to the intended brightness is one issue I am having. The other is the constant flicker I notice when running lower brightness. It is almost invisible when I go over 180 in brightness.
I posted on the subreddit for FastLED and got advice from someone experiencing the same thing, that switched from WS2811 to WS2812. But I cannot find any single color WS2812 12V led strips using 2835 smd: Reddit - The heart of the internet

Another option is FastLED.setDither( 0 ); according to some research I did.
But I am pretty sure the flickering keeps going after I unplug the Arduino (keeping the power to the LED strips).

To explain my goal, I am replacing the original PCB that was included in the aftermarket lightbar, because I don’t want any animation when running lights turn on.
The only thing I want is when it receives power, it should light up to the specified value of brightness.
Did some testing where I thought I could only use the setup part of the code, skipping the loop. But that results in the LED strips not lighting up when powered on.

You could use a RGB WS2812 as a single color.

In this case you don't need an addressable strip (2811/2812) at all, you can go with standard single color led strip

First, you should never connect a powered device to an non powered Arduino, you could damage the Arduino. You need to power both the arduino and strip at the same time.

Some 2811 will turn on full brightness when power is supplied and before valid data is recieved, it has nothing to do with noise.
You might try connecting a 10K ohm resistor between the Arduino data pin and ground and a 100 ohm resistor between the data pin and the strip

I think I did not clarify that I cannot replace the LED strips, and I cannot even visually inspect which type they are. They are enclosed in the housing for the lightbar. I’m just trying to modify it so it does not show an animation on startup.

The LED strips do not power on without any data cable attached.
I have a 1k resistor on each of the data lines (1 per led strip).

Not sure what you mean by that but as I said both the strips and Arduino need to be powered at the same time

I have a 1k resistor on each of the data lines (1 per led strip).

That may be too big, try what I suggested.

Tried this code, but I am still having the same issue where it has full brightness when it powers on, then adjusting the brightness after a few seconds:

#include <FastLED.h>
#define LED_PIN 16
#define NUM_LEDS 9

CRGB leds[NUM_LEDS];

void setup() {
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
delay(50);
FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(80);
FastLED.show(); // send clean frame immediately
}

void loop() {
  // Sätt LED-värden varje varv (samma data)
for (int i = 0; i < 5; i++) leds[i] = CRGB::White;

leds[5] = CRGB::White; leds[5].nscale8(220);
leds[6] = CRGB::White; leds[6].nscale8(210);
leds[7] = CRGB::White; leds[7].nscale8(180);
leds[8] = CRGB::White; leds[8].nscale8(130);

FastLED.show();

}

I don’t think the issue is in your code anymore. WS2811s latch whatever garbage is on the data line before the MCU has even finished resetting, so even if you pull the pin LOW in setup(), it’s already too late the strip has already seen a “fake” frame during power-up. One way around this is to hold the data line LOW immediately when the board powers up, not inside setup(). The usual fix is adding a physical pulldown resistor (like 4.7k–10k) on the data line so the strip never sees a floating signal during that first second. With a pulldown, the LEDs stay off until FastLED sends your first real frame.

Yes I think you are absolutely right! I tried letting the Mega2560 boot and then I connected the data line, now I got the right brightness instantly.

I tried with a 10k resistor, and 1 LED section lit up, but nothing else happened.

How do I hold the data line low immediately, and not inside setup?

A 10k pulldown is often too weak on a Mega, so the data line still floats for a moment and the WS2811 sees noise. Use a stronger pulldown, something around 2.2k–4.7k, and place it close to the strip so the line is held firmly at 0 V from the very first microsecond of power-up. There’s no way to do this in firmware; the Arduino pin is always high-impedance during reset, so only the external resistor can keep the strip quiet until FastLED sends the first real frame.

By the way, the Mega2560 I am talking about is this clone which I had lying around: Mega 2560 PRO (Embed) CH340G/ATmega2560-16AU - Hardware, Software, Gadgets & Future Tech News

I will try your suggestion, do I still need the code you provided or does that not matter when you have a resistor in place?

With that Mega 2560 PRO it’s the same situation the pins still float during reset. If you add a proper pulldown (around 2.2k–4.7k) close to the strip, then you don’t need any special code at all. The resistor itself keeps the LEDs dark from the moment power comes on, and your existing FastLED code will work normally once the board finishes booting.

Let me know if that fixes the startup brightness on your setup.

I tried with a 4,7kohm resistor as close to the strip as possible (30cm in this case).
It sadly does not work, a few led sections light up instantly and changes brightness after a few seconds. The rest doesnt light up at all.

You’re seeing that because the strip’s data input is still picking up noise before the Mega finishes booting. A 4.7 k pulldown helps, but on some strips the input stage is so sensitive that it still floats unless the line is both damped and driven.

A simple thing that usually stabilises it is adding a small series resistor on the data line itself, something around 220–470 Ω. That resistor slows the edge enough that random spikes on the wire don’t register as valid data, especially when the board is in reset. Keeping the data wire shorter or twisted with ground also helps a lot, because long single wires act like antennas.

If after adding the series resistor the first LED sections still wake up on their own, then the only consistently reliable fix is to put a buffer like a 74HCT14/125 on the data line so the strip sees a hard low level until the MCU starts sending real data.

Hi, @joq3
Is this an existing brake light bar on a vehicle.
If so I wouldn't go modifying its performance, as there are vehicle safety codes that have to be followed to make the vehicle roadworthy.

Tom.... :smiley: :+1: :coffee: :australia:

Did you try my recommended resistor?

That is wrong see post #5
Has nothing to do with noise

I did some testing but did not manage to get it to work.

Then I remembered when I used code which did not have anything in the loop, the LED strip never powered on. Doesn’t this mean that the theory that garbage data is sent on the data pin on bootup is wrong? Shouldn’t I have the same issue here?

I have tried to create code that sets the correct brightness and everything during the setup phase, but it never worked until I placed parts of it in loop. Maybe it sends the setup data to early?

I really want to fix this issue. I actually tried with a WLED controller, with similar results. If I choose to load a preset after boot it will do full brightness for a second or two until correcting to the preset value. If I disable preset load on boot it is off, until I turn it on manually, and it loads correctly.