Adafruit NeoPixel Überguide Created by Phillip Burgess Last updated on 2019-04-06 11:16:47 PM UTC
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.
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.
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).
Amps. Some minor modifications are needed…Google around for “ATX power supply hack.” Note that the ATX 5V rail can be very unstable if there's no load on the 12V rail! Even larger (and scarier, and much more expensive) are laboratory power supplies with ratings into the hundreds of Amps. Sometimes this is what’s needed for architectural scale projects and large stage productions.
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.
Python & CircuitPython It's easy to use NeoPixel LEDs with Python or CircuitPython and the Adafruit CircuitPython NeoPIxel (https://adafru.it/yew) module. This module allows you to easily write Python code that controls your LEDs. You can use these LEDs with any CircuitPython microcontroller board or with a computer that has GPIO and Python thanks to Adafruit_Blinka, our CircuitPython-for-Python compatibility library (https://adafru.it/BSN).
Pi 5V to LED 5V Pi GND to LED GND Pi GPIO18 to LED Din On the Raspberry Pi, NeoPixels must be connected to GPIO10, GPIO12, GPIO18 or GPIO21 to work! CircuitPython Installation of NeoPixel Library You'll need to install the Adafruit CircuitPython NeoPixel (https://adafru.it/yew) library on your CircuitPython board. First make sure you are running the latest version of Adafruit CircuitPython (https://adafru.it/Amd) for your board.
You'll need to install the Adafruit_Blinka library that provides the CircuitPython support in Python. This may also require verifying you are running Python 3. Since each platform is a little different, and Linux changes often, please visit the CircuitPython on Linux guide to get your computer ready (https://adafru.
To light up all the NeoPixels green: pixels.fill((0, 255, 0)) That's all there is to getting started with CircuitPython and NeoPixel LEDs! Full Example Code import time import board import neopixel # On CircuitPlayground Express, and boards with built in status NeoPixel -> board.NEOPIXEL # Otherwise choose an open pin connected to the Data In of the NeoPixel strip, i.e. board.D1 pixel_pin = board.NEOPIXEL # On a Raspberry pi, use this instead, not all pins are supported #pixel_pin = board.
b = int(pos*3) else: pos -= 170 r = 0 g = int(pos*3) b = int(255 - pos*3) return (r, g, b) if ORDER == neopixel.RGB or ORDER == neopixel.GRB else (r, g, b, 0) def rainbow_cycle(wait): for j in range(255): for i in range(num_pixels): pixel_index = (i * 256 // num_pixels) + j pixels[i] = wheel(pixel_index & 255) pixels.show() time.sleep(wait) while True: # Comment this line out if you have RGBW/GRBW NeoPixels pixels.fill((255, 0, 0)) # Uncomment this line if you have RGBW/GRBW NeoPixels # pixels.
Downloads WS2812 Datasheet (used in some older items) (https://adafru.it/qta) WS2812B Datasheet (https://adafru.it/uaR) (used in some older items) SK6812 Datasheet (https://adafru.it/uaS) (used in all our strips as of 2016) NeoPixel 12-LED Ring EagleCAD PCB files on GitHub (https://adafru.it/qic) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) NeoPixel 16-LED Ring EagleCAD PCB files on GitHub (https://adafru.it/qic) Fritzing object in Adafruit Fritzing library (https://adafru.
NeoPixel 24-LED Ring EagleCAD PCB files on GitHub (https://adafru.it/qic) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) © Adafruit Industries https://learn.adafruit.
NeoPixel 1/4 60-LED Ring EagleCAD PCB files on GitHub (https://adafru.it/qic) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) NeoPixel Jewel EagleCAD PCB files on GitHub (https://adafru.it/ped) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) © Adafruit Industries https://learn.adafruit.
Breadboard Friendly NeoPixel Breakout EagleCAD PCB files on GitHub (https://adafru.it/rAt) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) © Adafruit Industries https://learn.adafruit.
NeoPixel NeoMatrix 8x8 EagleCAD PCB files on GitHub (https://adafru.it/rB8) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) © Adafruit Industries https://learn.adafruit.
NeoPixel Arduino Shield EagleCAD PCB files on GitHub (https://adafru.it/rCg) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) © Adafruit Industries https://learn.adafruit.
NeoPixel 8 Stick EagleCAD PCB files on GitHub (https://adafru.it/rCQ) Fritzing object in Adafruit Fritzing library (https://adafru.it/aP3) © Adafruit Industries https://learn.adafruit.
NeoPixel Strips and Strands 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 over 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.
© Adafruit Industries https://learn.adafruit.
For those using Circuit Playground Express (https://adafru.it/wpF) or just needing a “no soldering” option (as in most classrooms), we have a special half-meter, 30-LED NeoPixel strip with alligator clips attached (https://adafru.it/DIV). Easy! Mini Skinny RGB NeoPixel Strips © Adafruit Industries https://learn.adafruit.
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.it/lXb) 30 and 60 LED/meter strips are 7.
Side-Light NeoPixel strips have the interesting property of illuminating next to the strip rather than over it. They’re not quite as bright as regular NeoPixels, but may have interesting uses in tight spaces or for edge-lit acrylic. These strips are available in three densities on black flex-strip: 60 LEDs, 1 meter black strip (https://adafru.it/Et0) 90 LEDs, 1 meter black strip (https://adafru.it/Et1) 120 LEDs, 1 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.
This distinctive NeoPixel flex strip has a gorgeous diffused neon-like appearance thanks to its thick silicone casing. This strip contains 60 LED along the meter but in groups of 3-LEDs-per-pixel. So basically, in your NeoPixel program, this looks like a 20-pixel-long strand. Unlike the other varieties of NeoPixel strip, this one needs to be powered from 9 Volts (minimum) to 12 Volts (ideal) DC. NeoPixel RGB Neon-like LED Flex Strip with Silicone Tube - 1 meter (https://adafru.
A single-color ultraviolet variant of NeoPixel strip is available for special applications, currently one pixel density and backing color: 32 UV LEDs per meter, white strip (https://adafru.it/BZ5) This can provide unusual effects when combined with UV-reactive paints, fluorescent laser-cut acrylic, etc. The usual NeoPixel R, G and B channels translate to three individual UV diodes. So we recommend you pretty much just set all three channels to the same value, ranging from (0, 0, 0) to (255, 255, 255).
Like NeoPixel strips, these “strands” are flexible and can be wrapped around things. The pixels are spaced further apart (2 or 4 inches) with each pixel is sealed in its own tiny plastic capsule, making them weatherproof (but not rated for continuous submersion). There are 20 pixels in a strand. NeoPixel Strand — 20 LED 4" Pitch (https://adafru.it/Et3) NeoPixel Strand — 20 LEDs at 2" Pitch (https://adafru.
contiguous strip, up to a limit: 4 meters for 60 pixels/m strip, 5 meters for 30 pixels/m. For 30 and 60 pixels/meter strips, if purchasing less than a full reel (4 or 5 meters, respectively), the strip may or may not have 3-pin JST plugs soldered at one or both ends. These plugs are for factory testing and might be at either end — the plug does not always indicate the input end! Arrows printed on the strip show the actual data direction. You may need to solder your own wires or plug.
NeoPixel Rings NeoPixel rings are circular rigid printed circuit boards festooned with NeoPixel LEDs. Originally designed for our NeoPixel Goggles kit (http://adafru.it/2221), they proved so popular with other projects…timepieces, GPS wayfinders, jewelry, etc…that we now offer several sizes and varieties… Rather than list a zillion different links, we have a single landing page for selecting among all the different NeoPixel ring products: NeoPixel Ring Product Selector (http://adafru.
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 (http://adafru.it/3052) All measure 71 millimeters (2.8 inches) square and about 3.6 mm thick.
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.
The Pimoroni Unicorn Hat (http://adafru.it/2288) is aptly named after a mythical animal — normally we’ll say that NeoPixels don’t work with the Raspberry Pi, but Pimoroni has worked up some magical software (https://adafru.it/lCx) that makes this combination possible! It’s an 8x8 RGB matrix that fits neatly atop the Raspberry Pi Model A+, B+ or Pi 2. Due to the way Unicorn HAT works, you can't use your Pi's analog audio alongside it.
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) Side Light NeoPixel LED PCB Bar A half-meter rigid PCB tightly packed with 60 side-light NeoPixels. This is a strange animal but might be just the thing for compact light-painting projects or edge-lit signage.
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.
Surface-mount “5050” (5 millimeter square) NeoPixels 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.
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.
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 (https://adafru.it/aYM) that walks through the process of correctly installing Arduino libraries manually. A Simple Code Example: strandtest Launch the Arduino IDE.
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.
Then, in the setup() function, call begin() to prepare the data pin for NeoPixel output: void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' } The second line, strip.show(), isn’t absolutely necessary, it’s just there to be thorough. That function pushes data out to the pixels…since no colors have been set yet, this initializes all the NeoPixels to an initial “off” state in case some were left lit by a prior program.
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: uint32_t magenta = strip.
This returns a 32-bit merged RGB color value. This is always RGB, even if the “ColorHSV()” function (described below) was used. The number of pixels in a previously-declared strip can be queried using numPixels(): uint16_t n = strip.numPixels(); The overall brightness of all the LEDs can be adjusted using setBrightness(). This takes a single argument, a number in the range 0 (off) to 255 (max brightness). For example, to set a strip to 1/4 brightness: strip.
uint32_t rgbcolor = strip.ColorHSV(hue, saturation, value); If you just want a “pure color” (fully saturated and full brightness), the latter two arguments can be left off: uint32_t rgbcolor = strip.ColorHSV(hue); In either case, the resulting RGB value can then be passed to a pixel-setting function, e.g.: strip.fill(rgbcolor); There is no corresponding function to go the other way, from RGB to HSV.
Pixels Gobble RAM Each NeoPixel requires about 3 bytes of RAM. This doesn’t sound like very much, but when you start using dozens or even hundreds of pixels, and consider that the mainstream Arduino Uno only has 2 kilobytes of RAM (often much less after other libraries stake their claim), this can be a real problem! For using really large numbers of LEDs, you might need to step up to a more potent board like the Arduino Mega or Due.
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.
Tiled Matrices A tiled matrix is comprised of multiple smaller NeoPixel matrices. This is sometimes easier for assembly or for distributing power. All of the sub-matrices need to be the same size, and must be ordered in a predictable manner.
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.show() to update the display after drawing. The setBrightness() function is also available. The library includes a couple of example sketches for reference.
Advanced Coding FastLED Library If looking to boost your NeoPixel prowess, you may find everything you need in the FastLED library (https://adafru.it/eip). 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.
DMA NeoPixels for ARM Cortex-M0 Boards If you’re using a recent “M0” development board such as the Adafruit Feather M0, Circuit Playground Express or Arduino Zero, an alternate NeoPixel library (https://adafru.it/xBb) exploits these devices’ direct memory access (DMA) feature to operate more smoothly. Advanced Arduino sketches can then use interrupts with impunity, and code that depends on the millis() or micros() functions will not lose time.
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 (https://adafru.it/cDM): specifically for the PJRC Teensy 3.0 microcontroller board. Uses DMA to drive up to 8 NeoPixel strips concurrently with minimal processor load. Multiple boards can be cascaded for still larger displays. FadeCandy (https://adafru.it/cDN): also for Teensy 3.0.
Writing Your Own Library The WS2812 datasheet (https://adafru.it/cDB) explains the data transmission protocol. This is a self-clocking signal — there’s only one wire, not separate data and clock lines. “1” and “0” bits are indicated by varying the duty cycle of a fixed-frequency square wave. There’s a math goof in the datasheet’s timing values. Use these figures instead: Note that there’s nearly 25% “wiggle room” in the timing.
The data for pixel #0 (nearest the microcontroller) is issued first, then pixel #1, and so forth to the furthest pixel. This does not operate like a traditional shift register! After all the color data is sent, the data line must be held low for a minimum of 50 microseconds for the new colors to “latch.” You may want to dig through our Arduino library (https://adafru.it/aZU) for insights. The timing-critial parts are written in AVR assembly language, but it’s extensively commented with C-like pseudocode.
© Adafruit Industries https://learn.adafruit.