Hey Folks,
I am a rookie tryind to get into Arduino since 2 years. But in the past there where always some issues that forced me to delay my projects.
But since 4 weeks I am trying really hard...
And now I am at a point where I don't know how to proceed.
Basic information:
I want to build a LED-stripe to my cars interieur that shall have the same color thatn the cockpit and controls. If you open the door, the stripe shall lighten up to white white a sliding animation. If you close the door = vise versa.
Here is the code so far:
#include "FastLED.h"
#define NUM_LEDS 15
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
void setup()
{
Serial.begin(57600);
Serial.println("resetting");
LEDS.addLeds<WS2812B,DATA_PIN,GRB>(leds,NUM_LEDS);
LEDS.setBrightness(100);
for(int i = 0; i < NUM_LEDS; i++)
{leds[i] = CHSV(128, 255, 50);}
}
void DoorClose(){
for(int i = 0; i < NUM_LEDS; i++) // First slide the led in one direction
{
leds[i] = CHSV(105, 150, 130); // Set the i'th led to red
leds[i-1] = CHSV(105, 150, 90); // Set the i'th led to red
leds[i-2] = CHSV(128, 255, 50); // Set the i'th led to red
FastLED.show(); // Show the leds
delay(100); // Wait a little bit before we loop around and do it again
}
}
void DoorOpen(){
for(int i = (NUM_LEDS)-1; i >= 0; i--) // Now go in the other direction.
{
leds[i] = CHSV(55, 150, 100); // Set the i'th led to red
leds[i+1] = CHSV(55, 150, 130); // Set the i'th led to red
leds[i+2] = CHSV(55, 150, 170); // Set the i'th led to red
FastLED.show(); // Show the leds
delay(100); // Wait a little bit before we loop around and do it again
}
}
void loop()
{
static uint8_t hue = 0;
Serial.print("x");
DoorOpen();
delay(1000);
Serial.print("x");
DoorClose();
delay(1000);
}
And here is a YT-Clip of the programm running:
I know my code seems simple, but that is all what I can effort with my poor knowledge about programming. The terms [i+1] and [i+2] where the only option I had with my knowledge to add some kind of "fading" to it.
But here a some issues with it.
The greenish collor wil have a different brigthness in the end of the stripe and also the white color will have a sligthly lower brightness then the rest of the stripe at the last 2 pixels.
Another huge problem (maybe the more importantone) is that the ligths should change a lot slower. but by just increase the delay, the "Fake-fade" won't work anymore, because you can clearly see how every pixel is changin its values.
Some days before I found a nice code, where each pixel was somehow seperated into 16 sections. By that, it was able to lighten pixels up and down with a very smooth transition. but I lost the code and aren'T able to find it in the internet again.
Maybe someone can help me out?
Thanks in advance and seasonal greetings to all!
Dirk