user7936: I wish to blink all the strip. In the code below it just blink the first LED, how can I fix it?
Code:
#include <Adafruit_NeoPixel.h>


#define PIN 6
#define NUM_LEDS 24


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  strip.setPixelColor(0, 255, 255, 255);
  strip.show();
  delay(1000);
  strip.setPixelColor(0, 0, 0, 0);
  strip.show();
  delay(1000);
}


user31105: The first argument of setPixelColor is is the number of the led. In your case 0, so the first led.
Instead use a for loop to set all the leds from 0 until (excluding) 24 (which is stored in NUM_LEDS).
void loop()
{
  for (int led = 0; led < NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, 255, 255, 255);
  }
  strip.show();
  delay(1000);

  for (int led = 0; led < NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, 255, 255, 255);
  }
  strip.show();
  delay(1000);

To make the code better (shorter, but more important more maintainable, and reducing code duplication), create a separate function:
void loop() 
{
  setLeds(255);
  setLeds(0);
}

void setLeds(int intensity)
{
  for (int led = 0; led < NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, intensity, intensity, intensity);
  }

  strip.show();
  delay(1000);
}


7936: <p>I wish to blink all the strip. In the code below it just blink the first LED, how can I fix it?</p>

<p>Code:</p>

<pre><code>#include &lt;Adafruit_NeoPixel.h&gt;


#define PIN 6
#define NUM_LEDS 24


Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);


void setup() {
  strip.begin();
  strip.show();
}

void loop() {
  strip.setPixelColor(0, 255, 255, 255);
  strip.show();
  delay(1000);
  strip.setPixelColor(0, 0, 0, 0);
  strip.show();
  delay(1000);
}
</code></pre>
 31105: <p>The first argument of <code>setPixelColor</code> is is the number of the led. In your case 0, so the first led.</p>

<p>Instead use a <code>for</code> loop to set all the leds from 0 until (excluding) 24 (which is stored in <code>NUM_LEDS</code>).</p>

<pre><code>void loop()
{
  for (int led = 0; led &lt; NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, 255, 255, 255);
  }
  strip.show();
  delay(1000);

  for (int led = 0; led &lt; NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, 255, 255, 255);
  }
  strip.show();
  delay(1000);
</code></pre>

<p>To make the code better (shorter, but more important more maintainable, and reducing code duplication), create a separate function:</p>

<pre><code>void loop() 
{
  setLeds(255);
  setLeds(0);
}

void setLeds(int intensity)
{
  for (int led = 0; led &lt; NUM_LEDS ; led++)
  {
    strip.setPixelColor(led, intensity, intensity, intensity);
  }

  strip.show();
  delay(1000);
}
</code></pre>
