New Guy learning need help bad

hello, Im here trying to learn to write some code. As you can tell I am a rookie at this, im stuck on this little task, because i dont know or understand the terminology so please bear with me in my code. I have a strip of 40 addressable leds going back and forth like the knightrider pattern i have learned alittle to get to that point but now i would like to add in a solid fill to the mix in which once the last led returns from the 40th led back down to led0 that the entire led strip would be lit on a solid color till i cut power off. i dont know how to even begin to write that part of the code. thanks for any help or advise you give. Here is my code so far:

#include <FastLED.h>

#define NUM_LEDS 40
#define LED_PIN 4

CRGB leds[NUM_LEDS];





void setup() {
  // put your setup code here, to run once:
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(20); //0-255 brightness
   


}


void loop() {
  // put your main code here, to run repeatedly:
  for(int i = 0; i <NUM_LEDS; i++){
     leds[i] = CRGB::GhostWhite;
      FastLED.show();
     delay(75);
     leds[i] =CRGB::Black;
  }
       for(int i = NUM_LEDS-1; i >=0; i--){
    leds[i] = CRGB::GhostWhite;
    FastLED.show();
    delay(65); 
leds[i] = CRGB::Black;
     
}
  
}
  • As you probably know there is an array where each pixel colour is stored.
    When it comes time to make all pixels one colour, iterate thru the array to set the colour then show()
1 Like

@LarryD What does that look like in code form do you have an example, it would help for me to see and apply

This is a way to ask for almost ready to use code. With which you will learn almost nothing.

So at least what do you think ? Which line of code configures the led to be switched on?
which line of code configures the led to be switch off?

light up all leds means switch them all on switch no led off
repeat the switch on/off-pattern but remove the line of code that switches off.

Give yourself a tap and make an attempt do code it. Yes for sure!
If you imagine yourself on mars and the only way to get back to earth is coding.
You would surely learn to code!

Even if your modified code will not compile
we will see what you already understand and what you don't understand.
And then we can give good advice taylored to your needs with the biggest laerning-effect.

@StefanL38 thanks for the advice I will try it in the am?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.