2 color sine fade - comments
This works, but the color change at the bottom of the sine is not smooth, and there is still some flickering. Although I tried using color and temperature correction, white is much brighter than blue and at low brightness, it shows some red and green.
Is there a better way to do this, and is color and temperature correction being used correctly? Thanks in advance.
#include <FastLED.h>
// Fixed definitions cannot change on the fly.
#define LED_DT 6 // Data pin to connect to the strip.
#define LED_CK 11 // Clock pin for WS2801 or APA102.
#define COLOR_ORDER GRB // It’s GRB for WS2812 and BGR for APA102.
#define LED_TYPE WS2812 // Using APA102, WS2812, WS2801. Don’t forget to change LEDS.addLeds.
#define NUM_LEDS 8 // Number of LED’s.
// Global variables can be changed on the fly.
uint8_t max_bright = 64; // Overall brightness definition. It can be changed on the fly.
CRGB leds[NUM_LEDS]; // Initialize our LED array.
int x = 0;
byte r = 0;
byte g = 0;
byte b = 0;
byte col = 0;
void setup() {
delay(3000); // Power-up safety delay.
Serial.begin(115200);
LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalSMD5050).setTemperature(Tungsten40W);
set_max_power_in_volts_and_milliamps(5, 500); // FastLED Power management set at 5V, 500mA.
}
void loop () {
EVERY_N_MILLISECONDS(30) {
int s = sin8(x);
x++;
if (x > 254 ) x = 0;
if (s == 255) {
switch (col) {
case 0:
r = 0;
g = 0;
b = 255;
break;
case 1:
r = 255;
g = 255;
b = 255;
break;
}
col++;
if (col == 2) col = 0;
}
for (int j = 0; j < NUM_LEDS; j++) {
leds[j].setRGB(r, g, b);
leds[j].fadeLightBy(s);
}
FastLED.show();
}
}