Datasheet

Arduino Library Use
Doxygen-generated documentation for the Adafruit_NeoPixel library is available here. (https://adafru.it/Etk)
It’s assumed at this point that you have the Adafruit_NeoPixel library for Arduino installed and have run the
strandtest example sketch successfully. If not, return to the prior page for directions to set that up.
To learn about writing your own NeoPixel sketches, let’s begin by dissecting the strandtest sketch
All NeoPixel sketches begin by including the header file:
The block of code that follows is mostly descriptive comments. Only a couple lines are really doing any work:
The first few lines assign numbers to the symbols “LED_PIN” and “LED_COUNT” for later reference. It doesn’t
need
to
be done this way, but makes it easier to change the pin and length where the NeoPixels are connected without
digging deeper into the code.
The last line declares a NeoPixel
object.
We’ll refer to this by name later to control the strip of pixels. There are three
parameters or
arguments
in parenthesis:
1. The number of sequential NeoPixels in the strip. In the example this is set to LED_COUNT, which was defined as
60 above, equal to 1 meter of medium-density strip. Change this to match the actual number you’re using.
2. The pin number to which the NeoPixel strip (or other device) is connected. Normally this would be a number, but
we previously declared the symbol LED_PIN to refer to it by name here.
3. A value indicating the type of NeoPixels that are connected. In most cases you can leave this off and pass just
two arguments; the example code is just being extra descriptive. If you have a supply of classic “V1” Flora pixels,
those require NEO_KHZ400 + NEO_RGB to be passed here. RGBW NeoPixels also require a different value here:
NEO_RGBW.
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1:
#define LED_PIN 6
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 60
// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
For through-hole 8mm NeoPixels, use NEO_RGB instead of NEO_GRB in the strip declaration. For RGBW
LEDs use NEO_RGBW (some RGBW strips use NEO_GRBW, so try that if you're getting unexpected results!)
© Adafruit Industries https://learn.adafruit.com/adafruit-neopixel-uberguide Page 71 of 100