#include <FastLED.h>
#define DATA_PIN 4
#define NUM_LEDS 194
CRGB leds[NUM_LEDS];
int index;
void setup()
{
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
fill_solid(leds, NUM_LEDS, CRGB( 0, 0, 0));
FastLED.show();
FastLED.setBrightness(255);
}
void loop()
{
EVERY_N_MILLISECONDS(2)
{
myRainbow( index);
index++;
if( index >= NUM_LEDS)
{
index = 0;
}
}
}
// Fill 194 leds with a hue from 0 to 255.
void myRainbow( int startLed)
{
const float hue_increment = float( 255) / float( NUM_LEDS);
int j = startLed;
for( int i=0; i<NUM_LEDS; i++, j++)
{
if( j >= NUM_LEDS) // index rolls beyond the array ?
{
j = 0; // wrap around
}
float thisHue = float( i) * hue_increment;
leds[j] = CHSV( int(thisHue), 255, 255);
}
FastLED.show();
}