Hi!
I'm trying to get a sin wave using beat8 function in FastLED library to make led strip fade.
beat8 allows to set the BMP minimum and maximum value (from 0 to 255).
The value I want to change is the BMP (beats per minute). However, as I change it, the wave glitches (as on the immage). It doesn't start at "0" but somewhere in the middle as the BMP value is updated.
My function looks like this
void draw_white_breathing_leds(){
Serial.print(breath_bright); Serial.print(","); //for debug
Serial.print(BMP); Serial.print(",");
Serial.println(speed_val);
FastLED.clear();
breath_bright = beatsin8(BMP, 0, bright_val);
if(breath_bright <= 0){ //Update BMP value when leds are off
BMP = speed_val;
}
else{}
for (int led = 0; led < num_leds_val; led++) {
leds[led] = CRGB(breath_bright,breath_bright,breath_bright);
}
FastLED.show();
}
I'm using rotary encoders to get those values so I'd like to keep the code as fast as possible. I tried many techniques to get a smooth fading wave. So far this one is my best attempt but still not enough.
How can I get a smooth sinusoidal/triangular wave with variable BMP?