Hello, I am new to this site so I apologize for not any missed guidlines.
Anyhow here is my issue.
I have a strip of 20 LEDs on my arduino uno. The code lights up the middle two LEDs first with a heatColor palette and moves outward from the center to the ends of the stip timed with millis.
The timing of turning on the LEDs works fine, however as every next set of LEDs come the colors start at whatever point the initial middle two LEDs are at in the palette cycle. I want each set to start from the beginning of the defined palette color as they come online.
This is to create a sunrise effect that grows across the strip. New to coding I appreciate any help I can get to remedy this.
#include <FastLED.h>
#define NUM_LEDS 20
#define DATA_PIN 3
CRGB leds[NUM_LEDS];
boolean lighting = true;
unsigned long event = 1000;
unsigned long event2 = 1500;
unsigned long event3 = 1600;
unsigned long event4 = 1700;
unsigned long event5 = 1800;
unsigned long event6 = 1900;
unsigned long event7 = 2000;
unsigned long event8 = 2100;
unsigned long event9 = 2200;
void setup(){
delay(500);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
}
void loop()
{
static uint8_t startIndex = 0;
startIndex = startIndex + 1; /* motion speed */
FillLEDsFromPaletteColors(startIndex);
}
void FillLEDsFromPaletteColors(uint8_t heatIndex)
{
if(lighting == true){
while(heatIndex < 240){
CRGB color = ColorFromPalette(HeatColors_p, heatIndex);
leds[9] = CRGB(color);
leds[10] = CRGB(color);
if(millis() >= event)leds[8] = CRGB(color);
if(millis() >= event)leds[11] = CRGB(color);
if(millis() >= event2)leds[7] = CRGB(color);
if(millis() >= event2)leds[12] = CRGB(color);
if(millis() >= event3)leds[6] = CRGB(color);
if(millis() >= event3)leds[13] = CRGB(color);
if(millis() >= event4)leds[5] = CRGB(color);
if(millis() >= event4)leds[14] = CRGB(color);
if(millis() >= event5)leds[4] = CRGB(color);
if(millis() >= event5)leds[15] = CRGB(color);
if(millis() >= event6)leds[3] = CRGB(color);
if(millis() >= event6)leds[16] = CRGB(color);
if(millis() >= event7)leds[2] = CRGB(color);
if(millis() >= event7)leds[17] = CRGB(color);
if(millis() >= event8)leds[1] = CRGB(color);
if(millis() >= event8)leds[18] = CRGB(color);
if(millis() >= event9)leds[0] = CRGB(color);
if(millis() >= event9)leds[19] = CRGB(color);
heatIndex += 1;
FastLED.show();
FastLED.delay(100); }
Boolean_Sunrise_9_LEDs.ino (2.07 KB)