WS2812b arduino uno and fadeled

Hi all, this is my first post here! I'm newbie of arduino and sorry for my noobism.
I've this setup:

This project is for my car headlights. A dynamic turn signal and DRL.

the turn signal work great, but the fade and stay function for DRL is very difficult for me.

This is my code

void RGBLoop(){
  for(int j = 0; j < 3; j++ ) {
    // Fade IN
    for(int k = 0; k < 256; k++) {
      switch(j) {
        case 0: setAll(k,0,0); break;
        case 1: setAll(0,k,0); break;
        case 2: setAll(0,0,k); break;
      }
      showStrip();
      delay(3);
    }

I try to turn on led strips in white color and fade from 0 to 255 and stay on but when fading to max brightness it's start to cycle again and again. How i can stop it to the max?

After this i try simply to turn on directly without fading (just to try) but when led goes on, the light flickering.

This is code

#include "FastLED.h"
#define NUM_LEDS 72
CRGB leds[NUM_LEDS];
#define PIN 6
const int buttonPin2 = 2;   
const int buttonPin3 = 3;
int buttonState2 = 0;   
int buttonState3 = 0;
int fadeAmount = 5;  // Set the amount to fade I usually do 5, 10, 15, 20, 25 etc even up to 255.



void setup()
{
  pinMode(buttonPin2, INPUT_PULLUP);
  pinMode(buttonPin3, INPUT_PULLUP);
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
 
  //FastLED.addLeds<NEOPIXEL, 8>(leds[0], NUM_LEDS); //led strip for front left
  //FastLED.addLeds<NEOPIXEL, 9>(leds[1], NUM_LEDS); //led strip for front right
}
// *** REPLACE FROM HERE ***


void TurnSignal() {
 
meteorRain(0xff,0x66,0x00,10, 40, true, 3);
}

void meteorRain(byte red, byte green, byte blue, byte meteorSize, byte meteorTrailDecay, boolean meteorRandomDecay, int SpeedDelay) { 
  //setAll(0,0,0);
 
  for(int i = 0; i < NUM_LEDS+NUM_LEDS; i++) {
   
   
    // fade brightness all LEDs one step
    for(int j=0; j<NUM_LEDS; j++) {
      if( (!meteorRandomDecay) || (random(10)>5) ) {
        fadeToBlack(j, meteorTrailDecay );       
      }
    }
   
    // draw meteor
    for(int j = 0; j < meteorSize; j++) {
      if( ( i-j <NUM_LEDS) && (i-j>=0) ) {
        setPixel(i-j, red, green, blue);
      }
    }
   
    showStrip();
    delay(SpeedDelay);
  }
}

void fadeToBlack(int ledNo, byte fadeValue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
    // NeoPixel
    uint32_t oldColor;
    uint8_t r, g, b;
    int value;
   
    oldColor = strip.getPixelColor(ledNo);
    r = (oldColor & 0x00ff0000UL) >> 16;
    g = (oldColor & 0x0000ff00UL) >> 8;
    b = (oldColor & 0x000000ffUL);

    r=(r<=10)? 0 : (int) r-(r*fadeValue/256);
    g=(g<=10)? 0 : (int) g-(g*fadeValue/256);
    b=(b<=10)? 0 : (int) b-(b*fadeValue/256);
   
    strip.setPixelColor(ledNo, r,g,b);
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds[ledNo].fadeToBlackBy( fadeValue );
 #endif 
  }


void DRL() {

fill_solid(leds, NUM_LEDS, CRGB::Blue); //set entire LED strip to Blue
 
}

void loop() {

buttonState2 = digitalRead(buttonPin2);

  if (buttonState2 == LOW) {

    TurnSignal();
   
  } else {
    FastLED.clear();
    FastLED.show();
  }

buttonState3 = digitalRead(buttonPin3);
 
  if (buttonState3 == LOW) {

    DRL();
   
  } else {
    FastLED.clear();
    FastLED.show();
  }
}






// *** REPLACE TO HERE ***

void showStrip() {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.show();
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   FastLED.show();
 #endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
 #ifdef ADAFRUIT_NEOPIXEL_H
   // NeoPixel
   strip.setPixelColor(Pixel, strip.Color(red, green, blue));
 #endif
 #ifndef ADAFRUIT_NEOPIXEL_H
   // FastLED
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
 #endif
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixel(i, red, green, blue);
  }
  showStrip();
}

But if i try to use the function in a new sketch, the led goes on correctly

#include "FastLED.h"
#define NUM_LEDS 72
CRGB leds[NUM_LEDS];
#define PIN 6


void setup() {
  // put your setup code here, to run once:
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}

void loop() {
  // put your main code here, to run repeatedly:
fill_solid(leds, NUM_LEDS, CRGB::Blue); //set entire LED strip to Blue
//showStrip();
}

Someone can help me? Thank you

I have this setup

Clearly you do not have his setup. Your code talks about buttons being pressed but your diagram shows no buttons at all.
If it is for car headlights then have you got a very long mains lead?

After this i try simply to turn on directly without fading (just to try) but when led goes on, the light flickering.

Well that is what that code is written to do. It is the meteorRain example from the library.

This sort of project has been done many times before but in many countries it is illegal to do this sort of modification on the road. Have you checked what the law is in your country?

Grumpy_Mike:
Clearly you do not have his setup. Your code talks about buttons being pressed but your diagram shows no buttons at all.

This is the setup of arduino and led strip. Sorry pins is not showed. Pin is on 2 and 3 and it works.

If it is for car headlights then have you got a very long mains lead?
Well that is what that code is written to do. It is the meteorRain example from the library.

Edit: i mean DRL void, not turn signal.

This sort of project has been done many times before but in many countries it is illegal to do this sort of modification on the road. Have you checked what the law is in your country?

It's for private use and not on the normal road

Pin is on 2 and 3 and it works.

Yes but how is it wired? Is it using an external pull up or pull down resistor? Is it wired between input and ground or input and 5V?
Words are simply too ambiguous when it comes to electronics. Yes you know what you have because you can see it, we only know what you tell us.

I try to turn on led strips in white color and fade from 0 to 255 and stay on but when fading to max brightness it's start to cycle again and again. How i can stop it to the max?

We don’t know because you only posted part of your code, the part that works. You did not post the code where you made the mistake of calling that function repeatedly, so we can’t tell you how to stop it.

Please read the how to use this forum sticky post it will tell you what you need to do to post an effective question here.

After you call the function DRL you never show the results by calling the show method so that might be something to do with why it flashes because it will only update the LEDs when you make another change.

The other thing is your strip wiring. You need a large capacitor across the power and ground directly wired at the start of the strip. Also because there are only thin foil connections along the strip by the time the voltage gets to the end it had dropped considerably. It is normal to wire power iamd ground nto both ends of the strip.