#include <FastLED.h>
#include <math.h>


int blue[3]    = {0,  0, 255};
int red[3]     = {255,  0, 0};
int green[3]   = {0,  255, 0};
int purple[3]  = {200,  0, 200};
int yellow[3]  = {200,  200, 0};
int skyblue[3] = {0,  200, 200};
int white[3]   = {200,  200, 200};

#define DATA_PIN    6
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS    20 //or more
CRGB leds[NUM_LEDS];
int i;
void fade_between(int a[3], int b[3], CRGB leds[NUM_LEDS], int del);
void set_definite(int a[3], CRGB leds[NUM_LEDS]);
#define BRIGHTNESS          250

void setup() {
  delay(3000);
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.show(); 
}
  
void loop()
{

      fade_between(white, blue, leds, 70);
      delay(2000);
      fade_between(blue, skyblue, leds, 70);
      delay(2000);
      fade_between(skyblue, green, leds, 70);
      delay(2000);
      fade_between(green, yellow, leds, 70);
      delay(2000);
      fade_between(yellow, red, leds, 70);
      delay(2000);
      fade_between(red, purple, leds, 70);
      delay(2000);
      fade_between(purple, white, leds, 70);
      delay(2000);
      fade_between(white, white, leds, 70);
      delay(2000);
}

void fade_between(int a[3], int b[3], CRGB leds[NUM_LEDS], int del) {
  int i, j, steps = 100;
  double dsteps = 100.0;
  double s1, s2, s3, tmp1, tmp2, tmp3;
  s1 = double((b[0] - a[0])) / dsteps; 
  s2 = double((b[1] - a[1])) / dsteps; 
  s3 = double((b[2] - a[2])) / dsteps;   
  tmp1 = a[0], tmp2 = a[1], tmp3 = a[2]; 
  for (i = 0; i < steps; i++) { 
  tmp1 += s1;
  tmp2 += s2; 
  tmp3 += s3;      
  for (j = 0; j < NUM_LEDS; j++)
  leds[j] = CRGB((int)round(tmp1), (int)round(tmp2), (int)round(tmp3)); 
  FastLED.show(); 
  delay(del);
  }
  set_definite(b, leds);
}

void set_definite(int a[3], CRGB leds[NUM_LEDS]) {
 int i; 
 for (i = 0; i < NUM_LEDS; i++) 
 leds[i] = CRGB(a[0], a[1], a[2]); 
 FastLED.show(); 
}
