Datasheet

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.
You can also (optionally) add a white component to the color at the end, like this:
setPixelColor() does not have an immediate effect on the LEDs. To “push” the color data to the strip, call show():
This updates the whole strip at once, and despite the extra step is actually a good thing. If every call to setPixelColor()
had an immediate effect, animation would appear jumpy rather than buttery smooth.
Multiple pixels can be set to the same color using the fill() function, which accepts one to three arguments. Typically it’s
called like this:
“color” is a packed 32-bit RGB (or RGBW) color value, as might be returned by strip.Color(). There is no option here for
separate red, green and blue, so call the Color() function to pack these into one value.
“first” is the index of the first pixel to fill, where 0 is the first pixel in the strip, and strip.numPixels() - 1 is the last. Must be
a positive value or 0.
“count” is the number of pixels to fill. Must be a positive value.
If called without a
count
argument (only color and first), this will from
first
to the end of the strip.
If called without
first
or
count
arguments (only color), the full strip will be set to the requested color.
If called with
no
arguments, the strip will be filled with black or “off,” but there’s also a different syntax which might be
easier to read:
You can query the color of a previously-set pixel using getPixelColor():
uint32_t magenta = strip.Color(255, 0, 255);
uint32_t greenishwhite = strip.Color(0, 64, 0, 64);
strip.show();
strip.fill(color, first, count);
strip.clear();
uint32_t color = strip.getPixelColor(11);
© Adafruit Industries https://learn.adafruit.com/adafruit-neopixel-uberguide Page 73 of 100