I have a problem. I am controlling my WS2812B using an Arduino, but I have a problem with the breathing effect. I created a class in the code that looks like this:
String breathDirection = "Down";
void breath_effect()
{
fill_solid(leds, TOTAL_LEDS, primary);
float currentBrightness = FastLED.getBrightness();
if (currentBrightness <= 1)
{
breathDirection = "Up";
}
else if (currentBrightness >= brightness)
{
breathDirection = "Down";
}
float brightnessCorrection = static_cast<float>(brightness) / 200;
if (breathDirection == "Down")
{
currentBrightness = currentBrightness - brightnessCorrection;
FastLED.setBrightness(currentBrightness);
}
else if (breathDirection == "Up")
{
Serial.println("Binnen");
Serial.println(currentBrightness);
currentBrightness = currentBrightness + brightnessCorrection;
Serial.println(currentBrightness);
FastLED.setBrightness(currentBrightness);
}
}
Now the breathing effect only works when the brightness
variable is set to 200. If I set it on a different value below 200, it goes down, but never comes up. The currentBrightness is each round the same value.
What is going wrong here?