#include <FastLED.h>
#define NUM_LEDS 8
#define DATA_PIN 2
static float pulseSpeed = 0.5; // Larger value gives faster pulse.
uint8_t hueA = 15; // Start hue at valueMin.
uint8_t satA = 230; // Start saturation at valueMin.
float valueMin = 120.0; // Pulse minimum value (Should be less then valueMax).
uint8_t hueB = 95; // End hue at valueMax.
uint8_t satB = 255; // End saturation at valueMax.
float valueMax = 255.0; // Pulse maximum value (Should be larger then valueMin).
uint8_t tempIndex = 0;
uint8_t hue = hueA; // Do Not Edit
uint8_t sat = satA; // Do Not Edit
float val = valueMin; // Do Not Edit
uint8_t hueDelta = hueA - hueB; // Do Not Edit
static float delta = (valueMax - valueMin) / 2.35040238; // Do Not Edit
CRGB leds[NUM_LEDS];
int pot=0;
void setup() {
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(200);
FastLED.setCorrection(TypicalPixelString);
pinMode(2, OUTPUT);
pinMode(A0, INPUT);
Serial.begin(9600);
}
void loop()
{
pot=analogRead(A0);
pot=map(pot,0,1023,0,4);
Serial.println(pot);
switch(pot)
{
case 0:
{
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.setCorrection(UncorrectedColor);
//leds[0] = CRGB::Red;
FastLED.show();
delay(2000);
FastLED.setCorrection(TypicalLEDStrip);
//leds[0] = CRGB::Green;
FastLED.show();
delay(2000);
FastLED.setCorrection(TypicalPixelString);
//leds[0] = CRGB::Blue;
FastLED.show();
delay(2000);
break;
}
case 1:
{
fill_solid(leds, NUM_LEDS, CRGB::White);
EVERY_N_SECONDS(1) {
tempIndex++;
if (tempIndex > 8) tempIndex = 0;
}
switch (tempIndex) {
case 0:
FastLED.setTemperature(Candle);
break;
case 1:
FastLED.setTemperature(Tungsten40W);
break;
case 2:
FastLED.setTemperature(Tungsten100W);
break;
case 3:
FastLED.setTemperature(Halogen);
break;
case 4:
FastLED.setTemperature(CarbonArc);
break;
case 5:
FastLED.setTemperature(HighNoonSun);
break;
case 6:
FastLED.setTemperature(DirectSunlight);
break;
case 7:
FastLED.setTemperature(OvercastSky);
break;
case 8:
FastLED.setTemperature(ClearBlueSky);
break;
}
FastLED.show();
break;
}
case 2:
{
fill_solid(leds, NUM_LEDS, CRGB::White);
FastLED.setCorrection(UncorrectedColor);
//leds[0] = CRGB::Red;
FastLED.show();
delay(2000);
FastLED.setCorrection(TypicalLEDStrip);
//leds[0] = CRGB::Green;
FastLED.show();
delay(2000);
FastLED.setCorrection(TypicalPixelString);
//leds[0] = CRGB::Blue;
FastLED.show();
delay(2000);
break;
}
case 3:
{
uint8_t sinBeat = beatsin8(30, 0, NUM_LEDS - 1, 0, 0);
uint8_t sinBeat2 = beatsin8(30, 0, NUM_LEDS - 1, 0, 85);
uint8_t sinBeat3 = beatsin8(30, 0, NUM_LEDS - 1, 0, 170);
// If you notice that your pattern is missing out certain LEDs, you
// will need to use the higher resolution beatsin16 instead. In this
// case remove the 3 lines above and replace them with the following:
// uint16_t sinBeat = beatsin16(30, 0, NUM_LEDS - 1, 0, 0);
// uint16_t sinBeat2 = beatsin16(30, 0, NUM_LEDS - 1, 0, 21845);
// uint16_t sinBeat3 = beatsin16(30, 0, NUM_LEDS - 1, 0, 43690);
leds[sinBeat] = CRGB::Green;
leds[sinBeat2] = CRGB::Blue;
leds[sinBeat3] = CRGB::Red;
EVERY_N_MILLISECONDS(1){
for(int i = 0; i < 4; i++) {
blur1d(leds, NUM_LEDS, 50);
}
}
//fadeToBlackBy(leds, NUM_LEDS, 10);
FastLED.show();
break;
}
case 4:
{ for (int i = 0; i < NUM_LEDS; i++) {
//leds[i] = CHSV(hue, 255, 255);
leds[i] = CHSV(hue + (i * 10), 255, 255);
}
EVERY_N_MILLISECONDS(15){
hue++;
}
FastLED.show();
}
}
}