#include <FastLED.h>
#define LED_PIN 8
#define NUM_LEDS 16
#define BRIGHTNESS 255
#define LED_TYPE WS2812
#define COLOR_ORDER GRB
CRGBArray<NUM_LEDS>leds;
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness( BRIGHTNESS );
}
void loop () {
cd77_sinelon_oneway(50, CRGB::Red, 5);
}
// Functions ======================
// Modification of sinelon() in FastLED's DemoReel100 example
void cd77_sinelon_oneway(uint8_t BPM, CRGB color, uint8_t fadeby)
{
// a colored dot going in one direction with fading tail
fadeToBlackBy( leds, NUM_LEDS, fadeby); //change fadeby to smaller or larger number to adjust the length of the tail.
uint8_t u= beat8(BPM,0); //BPM will allow you to adjust the speed the dot is moving.
uint16_t pos=map(u,0,255,0,NUM_LEDS);
leds[pos] = color;
FastLED.show();
}