Hey there! 😊
Well, my first guess would be that setBrightness only scales, and this may not result in zero (0) for the LED colors.
I do not have hardware laying around at the moment, but I'd try to see what happens if you force ldrvalue to zero.
Or better said: will this last part of the code make the strip dark (off) when forcing ldrvalue to zero
// FastLED.setBrightness(ldrValue);
FastLED.setBrightness( 0 );
for (int i=0;i<NUM_LEDS;i++){
leds[i].setRGB(255, 255, 255); //white color
FastLED.show();
}
My guess: either it will not turn off the LED strip, or "ldrvalue" never reaches zero. I haven't seen your serial output ... so I don't know.
An option would be to use force LEDs OFF when "ldrvalue" goes below a certain threshold ... ?
I took "10" as an arbitrary number ...
For example:
if(ldrvale<10) {
for (int i=0;i<NUM_LEDS;i++){
leds[i].setRGB(0, 0, 0); //LEDs OFF one at a time
FastLED.show();
}
} else {
FastLED.setBrightness(ldrValue);
for (int i=0;i<NUM_LEDS;i++){
leds[i].setRGB(255, 255, 255); //white color
FastLED.show();
}
}
Or maybe like this (does the same thing - just looks cleaner):
CRGB FinalColor;
...
if(ldrvalue<10) {
FinalColor = CRGB::Black;
} else {
FinalColor = CRGB::White;
}
FastLED.setBrightness(ldrValue);
for (int i=0;i<NUM_LEDS;i++){
leds[i] = FinalColor;
FastLED.show();
}
Note: if it still doesn't go dark, then try if moving the FastLED.setBrightness call in the if-then loop, something like this:
CRGB FinalColor;
...
if(ldrvalue<10) {
FastLED.setBrightness(255);
FinalColor = CRGB::Black;
} else {
FastLED.setBrightness(ldrValue);
FinalColor = CRGB::White;
}
for (int i=0;i<NUM_LEDS;i++){
leds[i] = FinalColor;
FastLED.show();
}
Hope this helps 😊