Hi all,
just wanted to check as i wanted to light up my ws2812 with 120 led, but the led after light up 1 round with purple and end up it auto restart arduino uno, is there anyone can guide me what should i change in the code? the led i wanted to do is just wanted to light up 3 round of 3 different color one by one led. is there possible, here is my code.
#include "FastLED.h"
// Number of leds in 1 strip
#define NUM_LEDS 120
unsigned long previousMillis = 0; // will store last time LED was updated
uint8_t i = 0;
// constants won't change :
const long interval = 500; // interval at which to blink (milliseconds)
DEFINE_GRADIENT_PALETTE( Sunrise_gp )
{
0, 19, 2, 39,
51, 0, 0, 51, // Midnight blue
94, 1, 29, 18, // Deepsky blue
149, 113, 78,188, // Medium blue
201, 25, 150, 205}; // Lightsky blue
CRGBPalette16 myPal = Sunrise_gp;
// Define the array of leds
CRGB ledstrip_1[NUM_LEDS];
CRGB ledstrip_2[NUM_LEDS];
CRGB ledstrip_3[NUM_LEDS];
CRGB ledstrip_4[NUM_LEDS];
void setup()
{
FastLED.addLeds<WS2812B, 4, GRB>(ledstrip_1, NUM_LEDS);
FastLED.addLeds<WS2812B, 5, GRB>(ledstrip_2, NUM_LEDS);
FastLED.addLeds<WS2812B, 6, GRB>(ledstrip_3, NUM_LEDS);
FastLED.addLeds<WS2812B, 7, GRB>(ledstrip_4, NUM_LEDS);
}
void loop()
{
sunrise();
FastLED.show();
}
void sunrise() {
// total sunrise length, in minutes
static const uint8_t sunriseLength = 3;
// how often (in seconds) should the heat color increase?
// for the default of 60 minutes, this should be about every 14 seconds
// 14 seconds x 256 gradient steps = 3,584 seconds = ~60 minutes
static const float interval = ((float)(sunriseLength * 60) / 256) * 1000;
// current gradient palette color index
static uint8_t heatIndex = 0; // start out at 0
// current used color palette
CRGB color = ColorFromPalette(myPal, heatIndex);
// fill the entire strip with the current color palette starting on 1 side
unsigned long currentMillis = millis();
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
ledstrip_1[i] = CRGB(color);
ledstrip_2[i] = CRGB(color);
ledstrip_3[i] = CRGB(color);
ledstrip_4[i] = CRGB(color);
// slowly increase the heat
EVERY_N_MILLISECONDS(interval ) {
// stop incrementing at 255, we don't want to overflow back to 0
if (heatIndex < 255) {
heatIndex++;
}
}
i = (i + 1) % NUM_LEDS;
}
}
I have solve just the current not enough