Datasheet

In the strandtest example, loop() doesn’t set any pixel colors on its own — it calls other functions
that create animated effects. So let’s ignore it for now and look ahead, inside the individual
functions, to see how the strip is controlled.
There are two ways to set the color of a pixel. The first is:
The first argument — n in this example — is the pixel number along the strip, starting from 0 closest
to the Arduino. If you have a strip of 30 pixels, they’re numbered 0 through 29. It’s a computer thing.
You’ll see various places in the code using a for loop, passing the loop counter variable as the pixel
number to this function, to set the values of multiple pixels.
The next three arguments are the pixel color, expressed as red, green and blue brightness levels,
where 0 is dimmest (off) and 255 is maximum brightness.
To set the 12th pixel (#11, counting from 0) to magenta (red + blue), you could write:
An alternate syntax has just two arguments:
Here, color is a 32-bit type that merges the red, green and blue values into a single number. This is
sometimes easier or faster for some (but not all) programs to work with; you’ll see the strandtest
code uses both syntaxes in different places.
You can also convert separate red, green and blue values into a single 32-bit type for later use:
Then later you can just pass “magenta as an argument to setPixelColor rather than the separate
red, green and blue numbers every time.
setPixelColor() does not have an immediate effect on the LEDs. Topush” the color data to the
strip, call show():
strip.setPixelColor(n, red, green, blue);
strip.setPixelColor(11, 255, 0, 255);
strip.setPixelColor(n, color);
uint32_t magenta = strip.Color(255, 0, 255);
strip.show();
© Adafruit Industries https://learn.adafruit.com/adafruit-neopixel-uberguide Page 19 of 39