#include "FastLED.h"
#define leds1PIN 8
#define leds2PIN 9
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define NUM_LEDS 50
#define BRIGHTNESS 96
#define FRAMES_PER_SECOND 120
#define START_SPEED 1
#define BLOCK_SIZE 6
CRGB leds [NUM_LEDS + BLOCK_SIZE ]; // space on the end to continue pattern
CRGB base[BLOCK_SIZE ];
CRGB mycyan2 = {0, 255, 127};
CHSV mycyan = {145,255,20};
#define RATE 10 //how fast block patern moves (smaller number is faster)
#define RATE_WAIT 3000 // between pulses
uint8_t pos = 0; // position along strip
uint8_t start_block_element=0; // position along block
void turnon()
{
for ( int y=0; y <NUM_LEDS;y++ )
{
leds[y] = mycyan ;
FastLED.delay(START_SPEED);
}
}
void initial_pattern()
{
while (pos < NUM_LEDS + BLOCK_SIZE )
{
EVERY_N_MILLISECONDS(RATE)
{
start_block_element=0;
// if starting not all block is shown
if ( pos < BLOCK_SIZE )
{
start_block_element =BLOCK_SIZE-(pos);
}
for ( uint8_t t= start_block_element; t < BLOCK_SIZE; t++)
{
leds[pos +(t-BLOCK_SIZE)] = base[t];
}
pos++;
}
FastLED.show(); // Display the pixels.
}
}
void setup() {
Serial.begin(9600);
Serial.print(" h="); Serial.print(mycyan.h);
Serial.print(" s="); Serial.print(mycyan.s);
Serial.print(" v="); Serial.println(mycyan.v);
FastLED.addLeds<WS2812,leds1PIN,COLOR_ORDER >(leds,NUM_LEDS);
FastLED.addLeds<WS2812,leds2PIN,COLOR_ORDER >(leds,NUM_LEDS);
// set master brightness contro]
FastLED.setBrightness(BRIGHTNESS);
// change BLOCK_SIZE to suit
base[0] = mycyan; // end of pattern -
base[1] = CRGB::Yellow;
base[2] = CRGB::Yellow;
base[3] = CRGB::White;
base[4] = CRGB::Yellow;
base[5] = CRGB::Yellow;
turnon();
initial_pattern();
}
void loop() {
EVERY_N_MILLISECONDS(RATE_WAIT)
{
pos=0;
initial_pattern();
}
}