Adafruit NeoPixel Überguide Created by Phillip Burgess Last updated on 2018-01-12 05:43:44 PM UTC
Guide Contents Guide Contents The Magic of NeoPixels 2 5 Important Things to Know About NeoPixels in General Can I use NeoPixels for POV (persistence of vision) displays? How about for light painting? Is there a limit to the number of NeoPixels in a chain? Form Factors NeoPixel Strips RGB NeoPixel Strips Mini Skinny RGB NeoPixel Strips RGBW NeoPixel Strips Finer Details About NeoPixel Strips NeoPixel Rings NeoPixel Ring Product Selector Finer Details About NeoPixel Rings 5 6 6 6 7 8 8 10 10 11 13 13 15
Basic Connections 32 Can NeoPixels be powered directly from the Arduino’s 5V pin? Best Practices 33 34 Improper use can damage your NeoPixels. Before diving in, be aware of the following: Powering NeoPixels Estimating Power Requirements 34 35 37 I estimate I need a 3.6 Amp power supply. I have a 10 Amp supply on-hand. Will this cause my NeoPixels to explode? 37 What about batteries and “Amp hours”? 37 I need to power LOTS of NeoPixels and don’t have a power supply that large.
DMA NeoPixels for ARM Cortex-M0 Boards Third-Party Libraries WS2811? WS2812? Why do I see two different names mentioned? Writing Your Own Library 57 58 58 58 My Microcontroller Isn’t Fast Enough to Do That 59 Downloads NeoPixel 12-LED Ring NeoPixel 16-LED Ring NeoPixel 24-LED Ring NeoPixel 1/4 60-LED Ring NeoPixel Jewel Breadboard Friendly NeoPixel Breakout NeoPixel NeoMatrix 8x8 NeoPixel Arduino Shield NeoPixel 8 Stick 60 60 60 61 62 63 64 65 66 67 © Adafruit Industries https://learn.adafruit.
The Magic of NeoPixels Incorporating scads of LEDs into an electronic project used to be a hairy prospect, a veritable rat’s nest of wires and code. The arrival of dedicated LED driver chips brought welcome relief, offloading grunt work from the microcontroller and allowing one to focus on the application. Much simpler, but still not “Christmas light” simple.
Can I use NeoPixels for POV (persistence of vision) displays? Not recommended. The refresh rate is relatively low (about 400 Hz), and color displays in fast motion may appear “speckled.” They look fine in stationary displays though (signs, decorations, jewelry, etc.). For POV use, DotStar strips will look much better (they have about a 20 KHz refresh rate).
Form Factors NeoPixel products are available in a zillion form factors…from individual tiny pixels to huge matrices…plus strips, rings and everything in-between. Pick a category from the left column for product links and tips & tricks specific to each type of NeoPixel. © Adafruit Industries https://learn.adafruit.
NeoPixel Strips The most popular type of NeoPixels are these flexible LED strips…they can be cut to length and fit into all manner of things. We’ve got a dozen varieties! Two vital things to be aware of: Though strips are described as “flexible,” they do not tolerate continuous and repeated bending. “Formable” might be a better word. A typical application is architecture, where they can be curved around columns and then stay put. Repeated flexing (as on costumes) will soon crack the solder connections.
© Adafruit Industries https://learn.adafruit.
Mini Skinny RGB NeoPixel Strips Mini Skinny NeoPixel strips are about half the width of classic NeoPixel strips. They’re available in two densities and backing colors: 30 LEDs per meter, white strip (http://adafru.it/2949) 30 LEDs per meter, black strip (http://adafru.it/2954) 60 LEDs per meter, white strip (https://adafru.it/lFs) 60 LEDs per meter, black strip (http://adafru.it/2964) 144 LEDs per meter, white strip (https://adafru.it/lXa) 144 LEDs per meter, black strip (https://adafru.
A recent addition is RGBW NeoPixel strips. These add a fourth LED element — pure white — which is more “true” and pleasing to the eye than white mixed from red+green+blue. Like the RGB strips, they’re available in different pixel densities and backing strip colors. 30 RGBW LEDs per meter, white strip (http://adafru.it/2832) 30 RGBW LEDs per meter, black strip (http://adafru.it/2824) 60 RGBW LEDs per meter, white strip (http://adafru.it/2842) 60 RGBW LEDs per meter, black strip (http://adafru.
releases acetic acid when curing, which can destroy electronics. It’s fine on the outside of the strip, but not the inside. Use GE Silicone II for sealing strip ends, or good ol’ hot melt glue. 2-sided carpet tape provides a light grip on the silicone sleeve; something like a Post-It Note. Or you can try clear duct tape over the top. All LED strips are manufactured in 1/2 meter segments that are then joined into a longer strip.
NeoPixel Rings NeoPixel rings are circular rigid printed circuit boards festooned with NeoPixel LEDs.
Number of Pixels Outer Diameter Inner Diameter 12 37 mm / 1.5" 23 mm / 1" 16 44.5 mm / 1.75" 31.75 mm / 1.25" 24 66 mm / 2.6" 52.5 mm / 2.05" 60 (4x 15-pixel arcs) 158 mm / 6.2" 145 mm / 5.7" All rings are about 3.6 millimeters / 0.15" thick (1.6 mm for PCB, 2 mm for NeoPixels). RGB NeoPixels are the most affordable and can produce millions of color combinations. RGBW NeoPixels offer an eye-pleasing “true” white in addition to RGB.
Finer Details About NeoPixel Rings When soldering wires to these rings, you need to be extra vigilant about solder blobs and short circuits. The spacing between components is very tight! It’s often easiest to insert the wire from the front and solder on the back. If using alligator clips, we recommend first soldering short jumper wires to the ring inputs and connecting the clips to those, for similar reasons.
There’s also a 24-pixel RGB ring (http://adafru.it/2268) specifically designed for the Particle (formerly Spark) Photon development board. This one’s not “see-through” like the others — the space at the center provides a socket for the Photon board (http://adafru.it/2721). © Adafruit Industries https://learn.adafruit.
NeoPixel Matrices NeoPixel matrices are two-dimensional grids of NeoPixels, all controlled from a single microcontroller pin. Rigid 8x8 NeoPixel Matrices Like NeoPixel rings, these 64-pixel matrices are assembled on a rigid printed circuit board and are available in both RGB and RGBW varieties. NeoPixel Matrix Product Selector All measure 71 millimeters (2.8 inches) square and about 3.6 mm thick. There are several mounting holes, and the DOUT pin allows multiple matrices to be linked in series.
Flexible NeoPixel matrices are available in three different sizes: 8x8 RGB pixels (http://adafru.it/2612) 16x16 RGB pixels (http://adafru.it/2547) 8x32 RGB pixels (http://adafru.it/2294) © Adafruit Industries https://learn.adafruit.
Size Dimensions Total # of LEDs Max Power Draw (approx) 8x8 80 mm / 3.15" square 64 19 Watts (3.8 Amps at 5 Volts) 16x16 160 mm / 6.3" square 256 77 Watts (15 Amps at 5 Volts) 8x32 320 mm x 80 mm / 12.6" x 3" 256 77 Watts (15 Amps at 5 Volts) Flex matrices are about 2 millimeters (0.08 inches) thick. Though called “flexible,” these matrices do not tolerate continuous and repeated bending. “Formable” might be a better word — they can be bent around a rigid or semi-rigid shape, like a hat.
NeoPixel Shields Though not all “Shields” in the strictly-speaking Arduino sense, a few NeoPixel products are designed to fit directly atop (or below) certain microcontroller boards… NeoPixel Shield for Arduino This 5x8 NeoPixel Shield for Arduino (http://adafru.it/1430) fits neatly atop an Arduino Uno or compatible boards (5V logic recommended). Like many of our NeoPixel products, they’re available in RGB and various RGBW pixel types: NeoPixel Shield Product Selector (https://adafru.
NeoPixel FeatherWing Quite possibly The Cutest Thing in the History of Cute Little Things, the NeoPixel FeatherWing (http://adafru.it/2945) is is 4x8 pixel matrix that fits perfectly atop any of our Feather microcontroller boards (https://adafru.it/l7B). The NeoPixels are normally controlled from digital pin 6, but pads on the bottom make this reassignable. In particular, the default pin for Feather Huzzah ESP8266 must be moved, try pin #15! The NeoPixel Featherwing is RGB only; there’s no RGBW version.
Particle/Spark NeoPixel Ring Kit Previously mentioned on the “Rings” page, but for posterity: this 24-pixel RGB ring (http://adafru.it/2268) is specifically designed for the Particle (formerly Spark) Photon development board. © Adafruit Industries https://learn.adafruit.
Other NeoPixel Shapes NeoPixel Stick The simplest thing…a row of 8 NeoPixels along a rigid circuit board. These make great bargraph indicators! Like our rings and matrices, NeoPixel sticks are available in RGB and RGBW varieties. NeoPixel Stick Product Selector (http://adafru.it/3039) All measure 51.1 x 10.2 millimeters (2.0 x 0.4 inches). NeoPixel Jewels © Adafruit Industries https://learn.adafruit.
When you need more “punch” than a single NeoPixel can provide, these 7-pixel jewels provide a lot of light in a compact shape. Again, RGB and RGBW varieties are available. NeoPixel Jewel Product Selector (http://adafru.it/3047) All measure 23 millimeters (0.9 inches) in diameter. 1/4 60 NeoPixel Ring © Adafruit Industries https://learn.adafruit.
Though originally designed to be used in groups of four to complete a 60 NeoPixel Ring, the individual 15pixel quarter rings can also be used to solve interesting design problems! RGB and RGBW are available. NeoPixel Ring Product Selector (http://adafru.it/3042) © Adafruit Industries https://learn.adafruit.
Individual NeoPixels If you need just a small number of pixels…or if ready-made shapes and strips don’t quite provide what you’re after…individual NeoPixels provide the most control over placement and quantity. Integrated NeoPixel Products Some individual NeoPixel products come ready to use, with a small PCB holding the LED, a decoupling capacitor for power, and points for connecting wires.
These are similar to the sewable Flora NeoPixels, but with a pin arrangement that (with the addition of headers) fits neatly into a breadboard for prototyping. Also available in two formats: Pack of 4 (http://adafru.it/1312), ready to use as-is. Sheet of 25 (http://adafru.it/1558), cut off as needed. For both types, headers (http://adafru.it/392) are optional and not included. Breadboard-Friendly NeoPixels measure 10.2 x 12.7 millimeters (0.4 x 0.5 inches) and are RGB only; there’s no RGBW version.
NeoPixel Mini PCB (http://adafru.it/1612) — sold in packs of 5 — are the smallest ready-to-use NeoPixel format. These have no mounting holes or soldering vias…wires must be soldered directly to pads on the back of the PCB. Each is about 10 millimeters (0.3 inches) in diameter. These are RGB only; there’s no RGBW version. Discrete NeoPixel Products For advanced users needing fully customized designs, discrete NeoPixel components are available.
Through-Hole NeoPixels Discrete Through-hole NeoPixels are available in two sizes: 8mm Diffused (http://adafru.it/1734) – pack of 5. 5mm Diffused (http://adafru.it/1938) – pack of 5. 5mm Clear (http://adafru.it/1837) have been discontinued, but the product page is still available if you require pinout information. Through-hole NeoPixels are RGB only; there’s no RGBW version. Use of a 0.1 μF capacitor (http://adafru.it/753) between + and ground on each pixel is strongly encouraged.
are available in many varieties: 5050 RGB LED (http://adafru.it/1655) – pack of 10. RGBW NeoPixel – Cool White – white case (http://adafru.it/2759) – pack of 10. RGBW NeoPixel – Neutral White – white case (http://adafru.it/2758) – pack of 10. RGBW NeoPixel – Warm White – white case (http://adafru.it/2757) – pack of 10. RGBW NeoPixel – Cool White – black case (http://adafru.it/2762) – pack of 10. RGBW NeoPixel – Neutral White – black case (http://adafru.it/2761) – pack of 10.
Tiny surface-mount “3535” (3.5 millimeters square) NeoPixels are available in two RGB versions; no RGBW is available. NeoPixel Mini 3535 RGB – white case (http://adafru.it/2659) – pack of 10. NeoPixel Mini 3535 RGB – black case (http://adafru.it/2686) – pack of 10. Decoupling capacitor recommended. As with the “5050” NeoPixels, white- and black-cased versions are functionally identical, this is an aesthetic design option. WS2811 Driver IC The NeoPixel driver logic is available separately (http://adafru.
Basic Connections To get started, let’s assume you have some model of Arduino microcontroller connected to the computer’s USB port. We’ll elaborate on the finer points of powering NeoPixels later, but in general you’ll usually be using a 5V DC power supply (e.g. “wall wart”) or — for wearable projects — a 3.7 Volt lithium-polymer battery. Identify the “input” end of your NeoPixel strip, pixel(s) or other device. On some, there will be a solder pad labeled “DIN” or “DI” (data input).
When using a DC power supply, or an especially large battery, we recommend adding a large capacitor (1000 µF, 6.3V or higher) across the + and – terminals. This prevents the initial onrush of current from damaging the pixels. See the photo on the next page for an example. With through-hole NeoPixels (5mm or 8mm), add a 0.1 µF capacitor between the + and – pins of EACH PIXEL. Individual pixels may misbehave without this “decoupling cap.
Best Practices Improper use can damage your NeoPixels. Before diving in, be aware of the following: Before connecting NeoPixels to any large power source (DC “wall wart” or even a large battery), add a capacitor (1000 µF, 6.3V or higher) across the + and – terminals as shown above. The capacitor buffers sudden changes in the current drawn by the strip. Place a 300 to 500 Ohm resistor between the Arduino data output pin and the input to the first NeoPixel.
Powering NeoPixels When connecting NeoPixels to any live power source or microcontroller, ALWAYS CONNECT GROUND (–) BEFORE ANYTHING ELSE. Conversely, disconnect ground last when separating. Adding a 300 to 500 Ohm resistor between your microcontroller's data pin and the data input on the first NeoPixel can help prevent voltage spikes that might otherwise damage your first pixel.
Three alkaline cells (such as AA batteries) can be installed in a battery holder (http://adafru.it/771) to provide 4.5 Volts. Though larger and heaver than the fancy lithium-polymer pack, they’re inexpensive and readily available. Four nickel-metal hydride (NiMH) rechargeable cells can similarly be used in a 4-cell battery holder (http://adafru.it/830) to provide 4.8 Volts. Make sure you only use NiMH cells in this configuration.
Be extremely cautious with bench power supplies. Some — even reputable, well-regarded brands — can produce a large voltage spike when initially switched on, instantly destroying your NeoPixels! If you use a bench supply, do not connect NeoPixels directly. Turn on the power supply first, let the voltage stabilize, then connect the pixels (GND first). Estimating Power Requirements Each individual NeoPixel draws up to 60 milliamps at maximum brightness white (red + green + blue).
continuously for one hour, or 1.3 Amps for 2 hours, and so forth. In reality, it’s not quite linear like that; most batteries have disproportionally shorter run times with a heavy load. Also, most batteries won’t take kindly to being discharged in an hour — this can even be dangerous! Select a battery sufficiently large that it will take at least a couple hours to run down. It’s both safer for you and better for the longevity of the battery.
Resistance is just as much a concern on tiny projects too! For wearable electronics we like conductive thread…it’s flexible and withstands hand washing. Downside is that it doesn’t carry much current. Here several strands of conductive thread have been grouped to provide better capacity for the + and – conductors down a pair of suspenders. (From the Pac Man Pixel Suspenders (https://adafru.it/ciD) guide.) Driving 5V NeoPixels from 3.3V Microcontrollers Increasingly, microcontrollers are running at 3.
Software NeoPixels got their start on Arduino, but have since branched out to other boards and languages. Pick a category from the left column for information specific to each coding environment. © Adafruit Industries https://learn.adafruit.
Arduino Library Installation Controlling NeoPixels “from scratch” is quite a challenge, so we provide a library letting you focus on the fun and interesting bits. The library works with most mainstream Arduino boards and derivatives: Uno, Mega, Leonardo, Micro, Adafruit Flora, etc. — most anything with an Atmel AVR 8-bit processor from 8 to 16 MHz — and also works with the Arduino Due and all varieties of the PJRC Teensy boards.
them in the subdirectory of your home folder. 4. Re-start the Arduino IDE if it’s currently running. Here’s a tutorial that walks through the process of correctly installing Arduino libraries manually. A Simple Code Example: strandtest Launch the Arduino IDE. From the File menu, select Sketchbook→Libraries→Adafruit_NeoPixel→strandtest (If the Adafruit_NeoPixel rollover menu is not present, the library has not been correctly installed, or the IDE needs to be restarted after installation.
Arduino Library Use 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: #include The block of code that follows is mostly descriptive comments.
left lit by a prior program. 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: strip.setPixelColor(n, red, green, blue); or, if you're using RGBW strips: strip.
You can also (optionally) add a white component to the color at the end, like this: uint32_t greenishwhite = strip.Color(0, 64, 0, 64); setPixelColor() does not have an immediate effect on the LEDs. To “push” the color data to the strip, call show(): strip.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.
The above declares two distinct NeoPixel objects, one each on pins 5 and 6, each containing 16 pixels and using the implied default type (NEO_KHZ800 + NEO_GRB). Can I connect multiple NeoPixel strips to the same Arduino pin? In many cases, yes. All the strips will then show exactly the same thing. This only works up to a point though…four strips on a single pin is a good and reliable number.
NeoMatrix Library The Adafruit_NeoMatrix library builds upon Adafruit_NeoPixel to create two-dimensional graphic displays using NeoPixels. You can then easily draw shapes, text and animation without having to calculate every X/Y pixel position. Small NeoPixel matrices are available in the shop. Larger displays can be formed using sections of NeoPixel strip, as shown in the photo above.
Let’s begin with the declaration for a single matrix, because it’s simpler to explain. We’ll be demonstrating the NeoPixel Shield for Arduino in this case — an 8x5 matrix of NeoPixels. When looking at this shield with the text in a readable orientation, the first pixel, #0, is at the top left. Each successive pixel is right one position — pixel 1 is directly to the right of pixel 0, and so forth. At the end of each row, the next pixel is at the left side of the next row.
Now the first pixel is at the top right. Pixels increment top-to-bottom — it’s now column major. The order of the columns is still progressive though. We declare the matrix thusly: Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 8, 6, NEO_MATRIX_TOP + NEO_MATRIX_RIGHT + NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE, NEO_GRB + NEO_KHZ800); The first two arguments — 5 and 8 — are the width and height of the matrix, in pixels. The third argument — 6 — is the pin number to which the NeoPixels are connected.
The last argument is exactly the same as with the NeoPixel library, indicating the type of LED pixels being used. In the majority of cases with the latest NeoPixel products, you can simply leave this argument off…the example code is just being extra descriptive. The point of this setup is that the rest of the sketch never needs to think about the layout of the matrix. Coordinate (0,0) for drawing graphics will always be at the top-left, regardless of the actual position of the first NeoPixel.
rotated 180 degrees. This is intentional and by design; it keeps the tile-to-tile wiring more consistent and simple. This rotation is not required for NEO_TILE_PROGRESSIVE. Tiles don’t need to be square! The above is just one possible layout. The display shown at the top of this page is three 10x8 tiles assembled from NeoPixel strip. Once the matrix is defined, the remainder of the project is similar to Adafruit_NeoPixel. Remember to use matrix.begin() in the setup() function and matrix.
human vision makes bright colors less discernible than dim ones. The Adafruit_NeoMatrix library uses gamma correction to select brightness levels that are visually (though not numerically) equidistant. There are 32 levels for red and blue, 64 levels for green. The Color() function performs the necessary conversion; you don’t need to do any math. It accepts 8-bit red, green and blue values, and returns a gamma-corrected 16-bit color that can then be passed to other drawing functions.
CircuitPython CircuitPython is Adafruit's branch of MicroPython designed to simplify experimentation and education on modern lowcost microcontrollers. It makes it easier than ever to get prototyping by requiring no upfront desktop software downloads. With CircuitPython you can write clean and simple Python code to control hardware instead of having to use complex low-level languages like C or C++ (what Arduino uses for programming).
# CircuitPython demo - NeoPixel import board import neopixel import time pixpin = board.D1 numpix = 10 strip = neopixel.NeoPixel(pixpin, numpix, brightness=0.3, auto_write=False) def wheel(pos): # Input a value 0 to 255 to get a color value. # The colours are a transition r - g - b - back to r.
© Adafruit Industries https://learn.adafruit.
Advanced Coding FastLED Library If looking to boost your NeoPixel prowess, you may find everything you need in the FastLED library. It’s an alternative to the Adafruit_NeoPixel library, providing more advanced features like HSV color support, nondestructive brightness setting and high-speed mathematical operations.
approximately. However… That’s only the time needed to push the bits down the wire. The actual refresh rate will be something less than this, and can’t be estimated as a single number for all cases. It takes time to process each “frame” of animation. How much time depends on the complexity of the math and the efficiency of the code (for example, floating-point calculations can be relatively slow). The formula above gives a maximum theoretical rate, but that’s just a starting point.
Plus an 8-way concurrent NeoPixel DMA library. Third-Party Libraries In addition to the previously-mentioned FastLED library, NeoPixel-compatible libraries have been developed for devices beyond Arduino. Please keep in mind that Adafruit did not develop any of this code and can’t fix bugs or offer technical help. This is Wild West stuff. OctoWS2811: specifically for the PJRC Teensy 3.0 microcontroller board. Uses DMA to drive up to 8 NeoPixel strips concurrently with minimal processor load.
Note that there’s nearly 25% “wiggle room” in the timing. So if your code can’t match the recommended times exactly, it’s usually okay, as long as it’s close. There are three bytes of data for each pixel. These should be issued in green, red, blue order, with the most-significant bit first. The data for pixel #0 (nearest the microcontroller) is issued first, then pixel #1, and so forth to the furthest pixel.
Downloads WS2812 Datasheet (used in some older items) WS2812B Datasheet (used in some older items) SK6812 Datasheet (used in all our strips as of 2016) NeoPixel 12-LED Ring EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library NeoPixel 16-LED Ring EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
NeoPixel 24-LED Ring EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
NeoPixel 1/4 60-LED Ring EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
NeoPixel Jewel EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
Breadboard Friendly NeoPixel Breakout EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
NeoPixel NeoMatrix 8x8 EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
NeoPixel Arduino Shield EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
NeoPixel 8 Stick EagleCAD PCB files on GitHub Fritzing object in Adafruit Fritzing library © Adafruit Industries https://learn.adafruit.
© Adafruit Industries Last Updated: 2018-01-12 05:43:43 PM UTC Page 68 of 68