Hello all,
First i like to introduce myself, I am marco and living in the netherlands i am a conveyor belt technician and in my spare time i like to learn all about programming arduino.
I just started a few months ago so i am still a newbie, but i want to learn as much as possible.
My first real project will involve leds, since there is already to much waste ocross the world, i like to make something i could also use. So i decide to make a light for my sons room which simulates the natural day and night light.
I have learned much from reading this forum and examples on internet.
I have made my own simple sketches and learned much from changing examples to what i liked and most of it went well.
But now i am stuck on some code and have to reach out for help.
I have a code which works fairly well, but i am trying to change the direction of the leds which i cant get to work.
Now all the leds turn on at the same time and slowly go up in brightness, i like to learn how i can change that into leds lighting up one after the other till all are on.
#include "FastLED.h"
// Number of leds in 1 strip
#define NUM_LEDS 84
DEFINE_GRADIENT_PALETTE( Sunup_gp )
{
0, 0, 0, 0, // Black
51, 25, 25, 112, // Midnight blue
101, 0, 0, 205, // Medium blue
151, 0, 91, 225, // Deepsky blue
178, 135, 206, 250, // Lightsky blue
255, 50, 50, 200}; // Daglicht
CRGBPalette16 myPal = Sunup_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()
{
delay( 3000 ); // power-up safety delay
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 = 60;
// 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
// HeatColors_p is a gradient palette built in to FastLED
// that fades from black to red, orange, yellow, white
// feel free to use another palette or define your own custom one
CRGB color = ColorFromPalette(myPal, heatIndex);
// fill the entire strip with the current color
fill_solid(ledstrip_1, NUM_LEDS, color);
fill_solid(ledstrip_2, NUM_LEDS, color);
fill_solid(ledstrip_3, NUM_LEDS, color);
fill_solid(ledstrip_4, NUM_LEDS, 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++;
}
}
}
Also there is a curious thing if i use my own palette with brightness, which fades down after the sunrise is completed, but when i use a pre-defined palette like lava or ocean colors, the brightness does not change after completion