#include "FastLED.h"
#define NUM_LEDS 12 // Enter the total number of LEDs on the strip
#define PIN 5 // LED signal Pin
int LightWidth = 3; //Set the number of active LED's
int delayDuration = 400;
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(9600);
FastLED.addLeds<WS2812B, PIN, GRB>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setMaxPowerInVoltsAndMilliamps(5, 500); // limit power of LED strip to 5V, 500mA
FastLED.clear(); // Init LEDs to "off"
}
void loop() {
//////(int red, int green, int blue, int LightWidth, int delayDuration)
Beacon(204, 136, 0, LightWidth, delayDuration);
}
void Beacon(int red, int green, int blue, int LightWidth, int delayDuration){
int LightWidthFix = LightWidth - 1;
for(int i = 0; i <= ((NUM_LEDS -LightWidth) + LightWidthFix); i++) {
FastLED.clear();
FastLED.show();
leds[i].setRGB(red/10, green/10, blue/10); ///Create Primary Leading LED
int j; ///Create second Trailing LED
if (i < LightWidthFix ) {
j = (i + NUM_LEDS) - LightWidthFix;
leds[j].setRGB(red/10, green/10, blue/10);
}
else{
j = i -LightWidthFix;
leds[j].setRGB(red/10, green/10, blue/10);
}
if ((i>0)&&(i<LightWidthFix)){ ///Fill from Low fix
Serial.println("FILL LOW");
for (int l = i; l >= 0; l--) {
leds[l].setRGB(red, green, blue);
}
}
if ((j<NUM_LEDS)&&(j>(NUM_LEDS-LightWidth))){ ///Fill To High fix
Serial.println("FILL HIGH");
for (int l = j; l < NUM_LEDS; l++) {
leds[l].setRGB(red, green, blue);
}
}
if ((i>=LightWidthFix)&&(j<=(NUM_LEDS-LightWidth))){ ///Fill To Main Cycle
Serial.println("FILL MAIN");
for (int t = 0; t <= LightWidthFix; t++){
leds[j+t].setRGB(red, green, blue);
}
}
FastLED.show();
delay(delayDuration);
}
}