#include "FastLED.h"
/***************************************
* Hardware definitions *
***************************************/
#define NUM_LEDS 50
#define LED_DATA_PIN 3
/***************************************/
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(9600);
Serial.println("Hello World!");
FastLED.addLeds<WS2812B, LED_DATA_PIN, GRB>(leds, NUM_LEDS);
}
//Lights 0 to 255
int state = 1;
void loop()
{
for(int i=0;i<NUM_LEDS;i++)
{
float normalizedInterator = (float)i/NUM_LEDS;
if(normalizedInterator <= 0.5f){
float redValue = 255-((normalizedInterator/0.5f)*255);
float greenValue = (normalizedInterator/0.5f)*255;
leds[i] = CRGB(redValue, greenValue, 0);
}
else if(normalizedInterator >= 0.5f)
{
float normalizedInterator2 = normalizedInterator-0.5f;
float greenValue = 255-((normalizedInterator2/0.5f)*255);
float blueValue = (normalizedInterator2/0.5f)*255;
leds[i] = CRGB(0, greenValue, blueValue);
}
//leds[i] = CRGB(((float)i/(float)NUM_LEDS)*255, 0, 0);
FastLED.show();
delay(100);
}
delay(1000);
for(int i=0;i<NUM_LEDS;i++)
{
leds[i] = CRGB(0,0,0);
}
/*
leds[0] =0xFF007F;
FastLED.show();
delay(200);
*/
}