How to use "WS2812_Definitions.h" with Neopixel Library?

DonpK:
I have included at the beginning of my sketch:

#include <Adafruit_NeoPixel.h>
#include "WS2812_Definitions.h"

Will this enable me to use the color names from Definition.h in the body of my sketch such as:

leds.setPixelColor(0, DARKORANGE);

Yes.

The #include "WS2812_Definitions.h" produces a compiler error. Am I misunderstanding the purpose of #include "WS2812_Definitions.h"?

You should have posted the compiler error, (within code tags, needless to say).

My guess is that you don't have that file in your sketch directory. It's not a part of the "Adafruit_NeoPixel" library, and must be downloaded separately and placed into the folder that holds your sketch.

To make things easier, I've attached a copy of the "WS2812_Definitions.h" file. As mentioned, just place it in your sketch folder before opening the sketch, and it will appear on a second tab in the IDE when you open the sketch.

Then, in your sketch, you can use all of those defines by name, like "DARKORANGE", "SEASHELL", "STEELBLUE" etc etc

So, for example, instead of this:-leds.setPixelColor(0, 0xFF00FF);    // Set the first LED to full red, no green, full blueyou could do this:-leds.setPixelColor(0, MAGENTA);    // Set the first LED to full red, no green, full blue

WS2812_Definitions.h (4.21 KB)