First of all, you didn't provide any info concerning what library you're using and where you got stuck.
So I'll just assume you're using FastLED, and since the issue isn't super complex, I can give you pretty much all the code you may need.
Looking at the drawing, the LEDs are positioned like it is one single strip.
The main line is 14 LEDs (LEDs 0-13), and at LED 10, we see 2x 5 LEDs (14-18 and 19-23), making it a total of 24 LEDs (the LED array starts counting at zero, so 0-23).
The base pattern looks like this, when initially skipping the fact that the LEDs fade out:
0
1
2
3
4
5
6
7
8
9 + 14 + 19
10 + 15 + 20
11 + 16 + 21
12 + 17 + 22
13 + 18 + 23
Ā
We can do this in code (fading/clearing of LEDs not yet included):
for(int i=0; i<14; i++) {
leds[i] = CRGB(0,255,0);
if(i>8) {
leds[i+5] = CRGB(0,255,0);
leds[i+10]= CRGB(0,255,0);
}
FastLED.show();
delay(speeddelay); // determines speed, higher number = slower effect
}
Ā
So for LEDs 0 to 13, we set the LED to green.
If we reached LED number 10 (remember, we start counting at zero and not one, so LED 9, eg. >8, and up) we need to go sideways as well (14 to 18 and 19 to 23).
Next we need to add a fade to the code (you may need to experiment a little with the value "96" to get the desired amount of fade-out effect):
for(int i=0; i<14; i++) {
fadeToBlackBy(leds, 24, 96); // led array, number of LEDs, amount of darkening
leds[i] = CRGB(0,255,0);
if(i>8) {
leds[i+5] = CRGB(0,255,0);
leds[i+10]= CRGB(0,255,0);
}
FastLED.show();
delay(100); // determines speed, higher number = slower effect
}
Ā
So,... all combined this should be something like this (untested, as I do not have my hardware handy at the moment), with the delay and color as a parameter:
#define FASTLED_INTERNAL // just used to mute the Pragma messages when compiling
#include "FastLED.h"
#define NUM_LEDS 24
CRGB leds[NUM_LEDS];
#define PIN 6
void setup()
{
FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop()
{
cross_effect(100,96,CRGB(0,255,0));
}
void cross_effect(int speeddelay, int DarkfadeAmount, CRGB LEDColor) {
for(int i=0; i<14; i++) {
fadeToBlackBy(leds, NUM_LEDS, DarkfadeAmount); // fade all to black one step at a time
// values: led array, number of LEDs, amount of darkening
leds[i] = LEDColor;
if(i>8) {
leds[i+5] = LEDColor;
leds[i+10]= LEDColor;
}
FastLED.show();
delay(speeddelay); // determines speed, higher number = slower effect
}
}
Ā
Again: untested, and you may need to tinker a little with the values.
Ā