// Knight Rider Type Patterns by Chemdoc77
// Based on the DemoReel100 example of the FastLED library.
// Goes either back and forth with a tail or goes only forward with a tail.
#include "FastLED.h"
#define NUM_LEDS 7
#define chipset WS2812B //use WS2812B if not using NEOPIXEL products.
#define Data_pin 13
#define BRIGHTEST 100 // the BRIGHTEST range is from 0 to 255.
CRGB leds[NUM_LEDS];
//pre-declaration of functions
//void cd77_sinelon_oneway();
void cd77_sinelon();
void setup() {
//delay(2000); // power-up safety delay
FastLED.addLeds<chipset, Data_pin,GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); // uncomment ",GRB" if you use the WS2812B chipset.
FastLED.setBrightness(BRIGHTEST);
}
void loop () {
cd77_sinelon_oneway(30, CRGB::Red);
}
// Functions ======================
void cd77_sinelon_oneway(uint8_t BPM, CRGB color)
{
// a colored dot going in one direction with fading tail
fadeToBlackBy( leds, NUM_LEDS, 10); //change 10 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.
uint8_t pos = map(u, 0, 255, 0, NUM_LEDS);
leds[pos] = color;
FastLED.show();
}
void cd77_sinelon(uint8_t BPM, CRGB color )
{
// a colored dot sweeping back and forth, with fading tail
fadeToBlackBy( leds, NUM_LEDS, 20); //change 20 to smaller or larger number to adjust the length of the tail.
uint8_t pos = beatsin16(BPM, 0, NUM_LEDS); //BPM will allow you to adjust the speed the dot is moving.
leds[pos] = color;
FastLED.show();
}