user69750: I'm using ws2812b 2x2 LEDs and have it switching between green and red, but only one of my LEDs on my 2x2 is lighting up.
I'm using the "blink" FastLED sketch with Data pin 3 on my Arduino Uno, define led 4.
void loop() { 
 // Turn the LED on, then pause
 leds[0] = CRGB::Red;
 FastLED.show();
 delay(5000);
 // Now turn the LED off, then pause
 leds[0] = CRGB::Green;
 FastLED.show();
 delay(5000);
}


user31105: This is an addition to the answer of xbox gamer (which I upvoted), to prevent much duplicated code.
For loop
First we see, the 4 LEDs are made red or green (using green in the following case):
leds[0] = CRGB::Green;
leds[1] = CRGB::Green;
leds[2] = CRGB::Green;    
leds[3] = CRGB::Green;

For this a for loop can be used counting from 0 to (excluding) 4:
for (led = 0; led < 4; led++)
{
    leds[led] = CRGB::Green;
}

Variant 1: Color argument
Next we see the first and last lines are almost identical. For this we can make a function, and change the variable items (like the color) with a variable passed to that function, which is called an argument:
First we create the loop function:
void loop() 
{ 
   turnLEDs(CRGB::Red);   // Turn LEDs on (i.e. red), then pause
   turnLEDs(CRGB::Green); // Turn LEDs off (i.e. green), then pause
}

Then we need to make just a single function to change the color (place this before the loop function. The type of the color is enum HTMLColorCode, see http://fastled.io/docs/3.1/struct_c_r_g_b.html.
void turnLEDs(enum HTMLColorCode color)
{
    for (led = 0; led < 4; led++)
    {
        leds[led] = color;
    }
    FastLED.show();
    delay(5000);
}

Variant 2: Boolean argument
Another way, is to not pass the color, but pass ON or OFF, which is a boolean.
For this we can use the so-called ternary operator: a ? b : c which means: if a is true, use b, otherwise c. We get:
void turnLEDs(bool enable)
{
    for (led = 0; led < 4; led++)
    {
        leds[led] = enable ? CRGB::Red : CRGB::Green;
    }
    FastLED.show();
    delay(5000);
}

void loop() 
{ 
   turnLEDs(true);
   turnLEDs(false);
}


user69739: For changing the led color or making any other led to glow you have to put the led number instead of leds[led number]  in this case so your code will basically look like.
void loop() { 
 // Turn the LED on, then pause
 leds[0] = CRGB::Red;
 leds[1] = CRGB::Red;    
 leds[2] = CRGB::Red;
 leds[3] = CRGB::Red;
 FastLED.show();
 delay(5000);
 // Now turn the LED off, then pause
 leds[0] = CRGB::Green;
 leds[1] = CRGB::Green;
 leds[2] = CRGB::Green;    
 leds[3] = CRGB::Green;
 FastLED.show();
 delay(5000);
}

Hope this helps

69750: <p>I'm using ws2812b 2x2 LEDs and have it switching between green and red, but only one of my LEDs on my 2x2 is lighting up.</p>
<p>I'm using the &quot;blink&quot; FastLED sketch with Data pin 3 on my Arduino Uno, define led 4.</p>
<pre><code>void loop() { 
 // Turn the LED on, then pause
 leds[0] = CRGB::Red;
 FastLED.show();
 delay(5000);
 // Now turn the LED off, then pause
 leds[0] = CRGB::Green;
 FastLED.show();
 delay(5000);
}
</code></pre>
 31105: <p>This is an addition to the answer of xbox gamer (which I upvoted), to prevent much duplicated code.</p>
<p><strong><code>For</code> loop</strong></p>
<p>First we see, the 4 LEDs are made red or green (using green in the following case):</p>
<pre><code>leds[0] = CRGB::Green;
leds[1] = CRGB::Green;
leds[2] = CRGB::Green;    
leds[3] = CRGB::Green;
</code></pre>
<p>For this a <code>for</code> loop can be used counting from 0 to (excluding) 4:</p>
<pre><code>for (led = 0; led &lt; 4; led++)
{
    leds[led] = CRGB::Green;
}
</code></pre>
<p><strong>Variant 1: Color argument</strong></p>
<p>Next we see the first and last lines are almost identical. For this we can make a function, and change the variable items (like the color) with a variable passed to that function, which is called an argument:</p>
<p>First we create the <code>loop</code> function:</p>
<pre><code>void loop() 
{ 
   turnLEDs(CRGB::Red);   // Turn LEDs on (i.e. red), then pause
   turnLEDs(CRGB::Green); // Turn LEDs off (i.e. green), then pause
}
</code></pre>
<p>Then we need to make just a single function to change the color (place this before the <code>loop</code> function. The type of the color is <code>enum HTMLColorCode</code>, see <a href="http://fastled.io/docs/3.1/struct_c_r_g_b.html" rel="nofollow noreferrer">http://fastled.io/docs/3.1/struct_c_r_g_b.html</a>.</p>
<pre><code>void turnLEDs(enum HTMLColorCode color)
{
    for (led = 0; led &lt; 4; led++)
    {
        leds[led] = color;
    }
    FastLED.show();
    delay(5000);
}
</code></pre>
<p><strong>Variant 2: Boolean argument</strong></p>
<p>Another way, is to not pass the color, but pass ON or OFF, which is a boolean.
For this we can use the so-called ternary operator: <code>a ? b : c</code> which means: if <code>a</code> is true, use <code>b</code>, otherwise <code>c</code>. We get:</p>
<pre><code>void turnLEDs(bool enable)
{
    for (led = 0; led &lt; 4; led++)
    {
        leds[led] = enable ? CRGB::Red : CRGB::Green;
    }
    FastLED.show();
    delay(5000);
}

void loop() 
{ 
   turnLEDs(true);
   turnLEDs(false);
}
</code></pre>
 69739: <p>For changing the led color or making any other led to glow you have to put the led number instead of <code>leds[led number]</code>  in this case so your code will basically look like.</p>
<pre><code>void loop() { 
 // Turn the LED on, then pause
 leds[0] = CRGB::Red;
 leds[1] = CRGB::Red;    
 leds[2] = CRGB::Red;
 leds[3] = CRGB::Red;
 FastLED.show();
 delay(5000);
 // Now turn the LED off, then pause
 leds[0] = CRGB::Green;
 leds[1] = CRGB::Green;
 leds[2] = CRGB::Green;    
 leds[3] = CRGB::Green;
 FastLED.show();
 delay(5000);
}
</code></pre>
<p>Hope this helps</p>
