r/FastLED • u/joq3 • Dec 04 '25
Support Weird behavior, full brightness, then correcting?
I have a weird issue with FastLED and my WS2811 strips. When running the script below, as soon as I power on my Arduino it fades up the brightness. But the weird part it fades to full brightness, and then it corrects the brightness to the brightness I selected.
This happens however I set it up, if I remove the fade part it still happens. But the fade part confirmed to me that it is certainly a coding issue and not a hardware issue.
The video showing the issue (change in brightness happens at 5 seconds):
#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.clear();
FastLED.show();
// FADE-UP
for (int b = 0; b <= 140; b++) {
FastLED.setBrightness(b);
// Set color // Set color
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();
delay(5); // Fade speed
}
}
void loop() {
}
1
Upvotes
1
u/joq3 Dec 04 '25
Here’s the video, the brightness changes at exactly 5 second mark: https://imgur.com/ombzDzQ
1
u/sutaburosu [stavros] Dec 05 '25
I can't see your video (because imgur blocks the UK). The pin number you're using suggests an ESP32 is involved. The ESP's watchdog timer will intervene if loop() isn't called on a regular basis. Your code doesn't make it to loop() within 5 seconds of startup.
What does the serial monitor say during execution? You may have to increase the core debug level.
1
u/macegr Dec 06 '25
Very simple explanation. FastLED uses temporal dithering to get smoother brightness scaling when you use the global setBrightness command. This can only happen while the processor is being allowed to update background functions, easiest achieved by allowing loop() to run as much as possible. You’re blocking loop(), so temporal dithering is disabled until you get there, and so the brightness will jump to a new level when you finally allow loop() to run.
There are two ways to fix this: rearchitect your program to manage timing and ramping without any blocking loops (preferred). Or instead of delay() use FastLED.delay() which was designed exactly for this reason…it will run FastLED.show() internally for the specified amount of time, so you don’t block temporal dithering (and you can delete the .show() statement)
1
u/DJ_Swirl Dec 05 '25
I'm not a FadtLED expert, but few things to things to think about.
On start up on all of my code (even when not using Fastled) I put a small loop at the top of the setup to allow the board to settle.
Example
Serial.begin(115200);
Serial.print(i); Serial.print(" "); delay(250); } Serial.println();
Second, what board are you using? I see you are using Pin 16, check you make sure that pin doesn't have some type of boot status, it might be sending odd data.
Third, and just something I've always done, straight after setting up the Fastled is to set black, this way all the leds are in a known state, especially useful if the board has sent out some random data
FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS, MAX_MILLIAMPS); FastLED.setDither(true); fill_solid(leds, LED_COUNT, CRGB::Black); FastLED.show();
1
u/mindful_stone Dec 05 '25
I'm not an expert on any of this, but I have some questions, thoughts...
How/when exactly is power supplied to the lights? From the MCU or an independent supply?
- Is power already supplied to the lights before you power on the Arduino, or is that when the lights first get power?
- "power on" of what: the lights alone, or everything through power to/through the arduino?
Have you tried, if possible, to remove the code and MCU from the equation altogether and just provide power (no data line) directly to the lights? If so, what happens?
Does everything (lights, MCU, ???) connect to a common ground?
Do you have a capacitor or something somewhere that impacts how much power gets to the lights when?
Is there anything between your car battery and your lights/MCU that prevents an immediate supply of full juice?
0
u/ZachVorhies Zach Vorhies Dec 04 '25 edited Dec 04 '25
Weird. But your using one of the AVR boards right? You can try previous versions of FastLED and see if it works in one of the older versions. If so, then let me know and I'll file an issue.
I'd recommend a xiao board using esp32c3/c6/s3/dev as these use high resolution timings and you aren't too sure of what your leds actually are.
Update: Chat GPT says that it's an issue with WS2811:
● Looking at this issue, I can identify the problem with high precision:
This is almost certainly a WS2811 hardware power-on initialization
behavior, not a FastLED coding issue.
The Root Cause
WS2811 chips have a known characteristic: when power is first applied,
they initialize to an undefined state (often full white/brightness) before
the microcontroller boots and sends valid data. There's a time window of
~100ms to several seconds where:
Why the code confirms it's not software
The key evidence: "if I remove the fade part it still happens" - this
proves it's happening before your code executes the fade loop.
The Fix
Try adding this at the very start of setup():
void setup() {
FastLED.addLeds<WS2811, LED_PIN, RGB>(leds, NUM_LEDS);
FastLED.setBrightness(0); // Explicitly set to 0 first
FastLED.clear();
FastLED.show(); // Send "all off" command ASAP
// Small delay to ensure WS2811s latch the off state
delay(10);
// Now do your fade-up...
}
Hardware Solutions (if software fix insufficient)
- Add a 330Ω-470Ω resistor on the data line (close to first LED)
- Use a 74HCT245 level shifter with output enable control
- Power the strip slightly after the Arduino (relay/MOSFET on LED power)
Confidence: 95% - This matches the classic WS2811 power-on behavior
pattern reported widely in the FastLED community.