// https://www.reddit.com/r/FastLED/comments/17uhnis/how_to_do_a_smooth_transition_of_a_single_led/
#include <FastLED.h>
#define NUM_LEDS 100
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2812B, PB1, GRB>(leds, NUM_LEDS);
}
void loop() {
fill_solid(leds, NUM_LEDS, CRGB::DarkCyan);
// start the moon at the first pixel of the strip
static int moon_pos = 0;
wu_pixel1d(moon_pos, CRGB::White);
// move the moon by 1/256th of a pixel each frame
moon_pos = (moon_pos + 1) % (256 * NUM_LEDS);
FastLED.show();
delay(10);
}
void wu_pixel1d(uint16_t x, CRGB col) {
// extract the fractional part and derive its inverse
uint8_t xx = x & 0xff, ix = 255 - xx;
// find the pixel location for the 8.8 fixed point input position
uint8_t pos = x / 256;
// if the first pixel is within the bounds of the strip, plot it
if (pos < NUM_LEDS) {
leds[pos] += col % ix;
}
// if the second pixel is within the bounds of the strip, plot it
pos += 1;
if (pos < NUM_LEDS) {
leds[pos] += col % xx;
}
}