Why do you have the Second leds[ i ] = CRGB::Red; ? That memory is already Red.
You should clear you strip in the setup so that you know when entering the loop all are black, then don't need to do the [rr]FastLED.show();[/tt] as the first instruction in the loop. Your loop then would be call TurnSignal, show the LEDs, pause a smal bit, clear the LEDs, pause a bit.
Not sure why you have a show in your setup. You know how to use clear, and you're still asking how to clear in setup.
Remember that setup is stuff that only runs once.
Frankly, the first LED is on because it's probably broken if clear doesn't turn it off.
Only thing left in the code to maybe fiddle with is where you select addleds neopixels when there's a dedicated option for WS2812B from Fastled.
I actually think the problem may be using addleds Neopixels instead of addleds WS2812B. There's an extra thingy defining RGB order for the WS. Go back to the Fastled sample code and find that correct addleds line
Should clarify something- what kind of LEDs do you actually have in that strip?
WS2812, WS2812B, or something else? Take a close up picture of an LED if you're unsure.
I have WS2812B's, and they actually use GRB order instead of RGB.
My code uses:
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
And can you get a vid of your first LED staying on? I'm thinking you only think it's on because the cycle starts right after a clear and you don't see it. When I put a delay in the right spot, it shows that the first actually does turn off.
Use this. Stay consistent with which code you're using, and if it calls it NUM_LEDS or NUM_LEDS_PER_STRIP. It's whatever is defined at the very beginning of your code. No reason to use the long winded name.
void TurnSignal() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB(250, 100, 0); //A better shade of yellow. Don't use predefined color words. JMHO.
FastLED.show();
delay(40);
} //^^Turns on LEDs
delay(1200); //Keeps them on for this long
FastLED.clear();
FastLED.show(); //Turns them all off
delay(600); //Keeps them off for this long
}
That's worked a treat and as you said, you need to put the delay in just the right place to solve it. It didn't occur to me to delay how long they were on:
The next step is to add 2 other buttons for the other 2 functions. This 'sweep' is for a turn signal and the other functions will be a brake light and running lights. I'll start with the brake light I think but it will be working on the same strip (I'll have 10 strips stacked on top of each other to make a 15x10 pixel matrix) and the turn signal will look as if it's passing over the brake light when pressed.
I suppose the trick will be tracking where the turnsignal is along it's sequence so the red brake leds can be activated at any time without 'resetting' the turnsignal.
So I've been using this DemoReel100 often, its a great sketch. But I need some help trying to figure out how to pass an additional variable to the function.
I have 2 different LED strips of different lengths attached to 2 different PINS. I want to be able to call a function and send to it the strip number I want it applied to. Basically what I want to do is be able to call the function, let's say rainbow(), and pass it a variable that tells it which LED strip to use. Without using this SimplePatternList array of pointers, it would look like:
rainbow(1);
Somehow, I would like to incorporate the rainbow(1) into the SimplePatternList because this is such an elegant and easy way to control what you're sending to the LEDs.
Hope this makes sense.
J-M-L:
typedef void (*SimplePatternList[])();
defines SimplePatternList as a new type of array of pointers to functions
SimplePatternList gPatterns = { sinelon, };
Creates gPatterns as such an array and initializes it with only one element (thus at position 0) which is the pointer to the function sinelon() that you have somewhere else in your code