Hello! Slow fade flicker problem help please!
Loving FastLED, thank you! I’m trying to produce a very very slow breathe effect with sections of some White APA102 strip. My program is doing other stuff so I don’t want to use delays.
I’ve tried the standard (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0 which is lovley. But if I slow it down as much as I need I’m getting really heavy flickering as I near black. I’m slowing by increasing the figure mulitplied by Pi and dividing mills() from 2000 to 7000. Test programme below.
I also tried a simple sin wave test, programme also below but again when I get v low it flickers. I’m wondering if I’m going to need to sequentially step down R, G and B pixels (all white with my LEDs obvs!) in order to get a smooth fade at very low levels? That alos sounds tricky to me?
Arduino is a Mega 2560, running IDE 1.6.7 on a Mac.
Thank you in advance for any help, I’m a bit desperate!
Here’s the sin code:
/***********************************/
#include <FastLED.h>
#define NUM_LEDS 144
#define COLOR_ORDER GRB
#define LED_TYPE APA102
#define MAX_BRIGHTNESS 255
struct CRGB leds[NUM_LEDS];
void setup()
{
delay(1000);
LEDS.addLeds<LED_TYPE, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(MAX_BRIGHTNESS);
fill_solid( leds, NUM_LEDS, CRGB(255,255,255));
}
void loop()
{
drawBreathe();
//FastLED.show();
}
void drawBreathe() {
float in, breath;
for (in = 0; in < 6.283; in = in + 0.001){
breath = sin(in) * 127.5 + 127.5;
fill_solid( leds, NUM_LEDS, CRGB(breath,breath,breath));
FastLED.show();
}
}
/***********************************/
and the exp(sin(mills()) code:
/***********************************/
#include <FastLED.h>
#define NUM_LEDS 144
#define COLOR_ORDER GRB
#define LED_TYPE APA102
#define MAX_BRIGHTNESS 255
struct CRGB leds[NUM_LEDS];
void setup()
{
delay(1000);
LEDS.addLeds<LED_TYPE, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(MAX_BRIGHTNESS);
FastLED.clear();
fill_solid(leds, NUM_LEDS, CRGB::White);
}
void loop () {
float breath = (exp(sin(millis()/7000.0*PI)) - 0.36787944)108.0; // was (exp(sin(millis()/2000.0PI)) - 0.36787944)*108.0
FastLED.setBrightness(breath);
FastLED.show();
}
/***********************************/