#include <FastLED.h>
#define NUM_LEDS 25
#define DATA_PIN 21
CRGB leds[NUM_LEDS];
void setup() {
//Serial.begin(115200);
//Serial.println("Start ...");
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS).setCorrection(UncorrectedColor);
FastLED.setBrightness(getBrightCRT(255));
//FastLED.setMaxPowerInVoltsAndMilliamps(5, 5000);
//FastLED.setDither(0);
//FastLED.setMaxRefreshRate(100);
}
void loop() {
EVERY_N_MILLISECONDS(40) {
//mode_snake();
//mode_snake2();
mode_sparcle1();
leds[NUM_LEDS - 1] = 0xff0000; // хвост
FastLED.show();
}
}
byte getBrightCRT(byte val) {
return ((long)val * val * val + 130305) >> 16;
}
void mode_snake2() {
static uint16_t _offset;
EVERY_N_MILLISECONDS(20) {
_offset--;
// if (_offset ) _offset = 0;
}
#define LOW_P 155
for (int i = 0; i < NUM_LEDS; i++) {
{
uint8_t _s = triwave8((i * 10) + _offset);
if (_s < LOW_P) _s = LOW_P;
_s = map(_s, LOW_P, 255, 0, 255);
//map(value, fromLow, fromHigh, toLow, toHigh)
leds[i] = CHSV((_s / 3) + 160, 200, _s);
//leds[i].r = _s;
//leds[i].g = _s;
//leds[i].b = _s;
}
}
//blur1d(leds, NUM_LEDS, 33);
//fadeToBlackBy(leds, NUM_LEDS, 5);
}
void mode_sparcle1()
{
EVERY_N_MILLISECONDS(500) {
leds[random16(NUM_LEDS-1)]=CHSV(random8(),255,255);
}
leds[NUM_LEDS - 1] = 0x000000;
blur1d(leds, NUM_LEDS, 128);
}