Adafruit NeoPixel Überguide - SparkFun Electronics

Transcription

Adafruit NeoPixel ÜberguideCreated by Phillip BurgessLast updated on 2014-01-01 11:45:23 AM EST

Guide ContentsGuide Contents2The Magic of NeoPixels3Important Things to Know About NeoPixels in General3Adafruit NeoPixels are Available in the Following Products:4Important Things to Know About NeoPixel Strips5Arduino Library9Basic Connections9A Simple Code Example: strandtest10Pixels Gobble RAM13Powering NeoPixels14Estimating Power Requirements15Giant Power Supplies16Distributing Power17Driving 5V NeoPixels from 3.3V Microcontrollers17NeoMatrix Library19Layouts19Tiled Matrices22Other Layouts23RAM Again23Gamma Correction23Advanced Coding25Third-Party Libraries26Writing Your Own Library27 Adafruit xel-uberguidePage 2 of 28

The Magic of NeoPixelsIncorporating scads of LEDs into an electronic project used to be a hairy prospect, a veritablerat’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.The WS2812 Integrated Light Source — or NeoPixel in Adafruit parlance — is the latestadvance in the quest for a simple, scalable and affordable full-color LED. Red, green and blueLEDs are integrated alongside a driver chip into a tiny surface-mount package controlledthrough a single wire. They can be used individually, chained into longer strings or assembledinto still more interesting form-factors.“Any sufficiently advanced technology is indistinguishable from magic.” — Clarke’s ThirdLawImportant Things to Know About NeoPixels in GeneralNot all addressable LEDs are NeoPixels. “NeoPixel” is Adafruit’s brand for individuallyaddressable RGB color pixels and strips based on the WS2812 and WS2811 LED/drivers,using a single-wire control protocol. Other LED products we carry — WS2801 pixels,LPD8806 and “analog” strips — use different methodologies (and have their own tutorials).When seeking technical support in the forums, a solution can be found more quickly ifthe correct LED type is mentioned.NeoPixels don’t just light up on their own; they require a microcontroller (such as Arduino)and some programming. We provide some sample code to get you started. To create yourown effects and animation, you’ll need some programming practice. If this is a newexperience, work through some of the beginning Arduino tutorials to get a feel for thelanguage.NeoPixels aren’t the answer for every project. The control signal has very strict timingrequirements, and some development boards (such as Netduino or Raspberry Pi) can’treliably achieve this. This is why we continue to offer other LED types; some are moreadaptable to certain situations.Can I use NeoPixels for POV (persistence of vision) displays?Not recommended. The refresh rate is relatively low (about 400 Hz), and color displays infast motion may appear “speckled.” They look fine when stationary though. For POV use,LPD8806 strips (http://adafru.it/306) will look much better (they have about a 4 KHz refreshrate).Not recommended. The refresh rate is relatively low (about 400 Hz), and color displays in Adafruit xel-uberguidePage 3 of 28

fast motion may appear “speckled.” They look fine when stationary though. For POV use, ahref "http://www.adafruit.com/products/306" title "Link:http://www.adafruit.com/products/306" LPD8806 strips /a span class "pdf-shortlink" (http://adafru.it/306) /span will look much better (they have about a 4 KHz refreshrate). br How about for light painting?Definitely! The slower movement used for photographic light painting doesn’t accentuate thelimited refresh rate; the results look great, especially with a light diffuser.Definitely! The slower movement used for photographic light painting doesn’t accentuatethe limited refresh rate; the results look great, especially with a light diffuser. br Adafruit NeoPixels are Available in the Following Products:Neo Pixel Digital RGB LEDWeatherpro o f Strip: 30 LEDs permeter on a white backing strip.http://www.adafruit.com/products/1376 (http://adafru.it/1376)Sold by the meter, up to 5 meters perreel. Can be cut to shorter lengths (downto a single pixel).At peak brightness (all LEDs on, fullbrightness white), each 1-meter lengthdraws about 9.5 Watts (or just under 2Amps at 5 Volts). Mixed colors and lowerbrightness settings will use proportionallyless power.Neo Pixel Digital RGB LEDWeatherpro o f Strip: 30 LEDs permeter on a black backing strip.http://www.adafruit.com/products/1460 (http://adafru.it/1460)Sold by the meter, up to 5 meters perreel. Can be cut to shorter lengths (downto a single pixel).Power requirements are the same as thewhite-backed strip above.Neo Pixel Digital RGB LEDWeatherpro o f Strip: 60 LEDs permeter on a white backing strip.http://www.adafruit.com/products/1138 (http://adafru.it/1138)Double the pixel density! Sold by themeter, up to 4 meters per reel. Can becut to shorter lengths (down to a singlepixel).At peak brightness (all LEDs on, fullbrightness white), each 1-meter lengthdraws about 18 Watts (or about 3.6Amps at 5 Volts). Mixed colors and lowerbrightness settings will use proportionallyless power. Adafruit xel-uberguidePage 4 of 28

Neo Pixel Digital RGB LEDWeatherpro o f Strip: 60 LEDs permeter on a black backing strip.http://www.adafruit.com/products/1461 (http://adafru.it/1461)Sold by the meter, up to 4 meters perreel. Can be cut to shorter lengths (downto a single pixel).Power requirements are the same as thewhite-backed strip above.Neo Pixel Digital RGB LED Strip:144 LEDs per meter on a white backingstrip.http://www.adafruit.com/products/1507 (http://adafru.it/1507)Sold in 1-meter lengths only, with 3-pinJST connectors on both ends. Multiplemeters are not joined on a single reel.Can be cut to shorter lengths (down to asingle pixel). Originally this strip did nothave a weatherproof covering, but thelatest batches now include it.At peak brightness (all LEDs on, fullbrightness white), the full 1-meter lengthdraws about 35 watts (7 Amps at 5Volts). Mixed colors and lower brightnesssettings will use proportionally lesspower.Neo Pixel Digital RGB LED Strip:144 LEDs per meter on a black backingstrip.http://www.adafruit.com/products/1506 (http://adafru.it/1506)Sold in 1-meter lengths only, with 3-pinJST connectors on both ends. Multiplemeters are not joined on a single reel.Can be cut to shorter lengths (down to asingle pixel). Originally this strip did nothave a weatherproof covering, but thelatest batches now include it.Power requirements are the same as thewhite-backed strip above.The product list continues below. But first Important Things to Know About NeoPixel StripsNeoPixel strips are sold in one meter lengths. The 144 pixels/meter strips are alwaysseparate 1-meter lengths. For 60 and 30 pixels/meter strips, orders for multiple meters willbe a single contiguous strip, up to a limit: 4 meters for 60 pixels/meter strip, or 5 meters for30 pixels/meter strip.For 60 and 30 pixels/meter strips, if purchasing less than a full reel (4 or 5 meters,respectively), the strip may or may not have a 3-pin JST plug soldered to one end. Theseplugs are for factory testing and might be at either end — the plug does not always indicate Adafruit xel-uberguidePage 5 of 28

the input end! Arrows printed on the strip show the actual data direction.Although these strips are flexible, they do not tolerate continuous and repeated bending. Atypical application is architectural installations, where they can be curved around columnsand then stay put. Repeated flexing (as on costumes) will soon crack the solderconnections. For wearable use, either affix shorter segments to a semi-rigid base (e.g. ahat, BMX armor, etc.), or use the individual sewable NeoPixels shown later.The flex strips are enclosed in a weatherproof silicone sleeve, making them immune to rainand splashes, but are not recommended for continuous submersion. Early 144 pixel/meterstrips were not weatherproof, but the latest batches now include this feature.The silicone sleeve can be cut and removed for a slimmer profile, but the strip is no longerweatherproof.Very few glues will adhere to the weatherproof silicone sleeve. Using zip ties for a“mechanical” bond is usually faster and easier. The only two reliable glues we’ve found arePermatex 66B Clear RTV Silicone (not all silicone glues will work!) and Loctite PlasticsBonding System, a 2-part cyanoacrylate glue. The Permatex 66B silicone can also be usedto seal the open end of a cut strip.All strips are manufactured in 1/2 meter segments that are then joined into a longer strip.The pixel spacing across these joins is 2-3 millimeters different than the rest.Flo ra RGB Smart Neo Pixel(Versio n 2)http://www.adafruit.com/products/1260 (http://adafru.it/1260)Designed for wearables and “softcircuits” — these individual NeoPixels canbe sewn in using our stainless conductivethread (http://adafru.it/641).Sold in packs of 4.At peak output (white, max brightness),each pixel draws about 60 milliamps.Mixed colors and lower brightnesssettings will use proportionally lesspower.Flo ra RGB Smart Neo Pixel(Versio n 1)Disco ntinued, but listed here forcompatibility information. This earlierversion of our Flora NeoPixel can beidentified by a small driver chip on theback side (now integrated into the LED inVersion 2).The V1 and V2 pixels aren’tinterchangeable; each has differentsignal requirements. A project can mixboth types if they’re on separate pins; allV1 pixels on one pin, all V2 on another.The V1 pixels were originallyprogrammed using the Adafruit FloraPixellibrary. All new code should instead usethe Adafruit NeoPixellibrary (http://adafru.it/aZU), whichhandles both types. Adafruit xel-uberguidePage 6 of 28

Breadbo ard-friendly RGB SmartNeo Pixelhttp://www.adafruit.com/products/1312 (http://adafru.it/1312)Functionally similar to our Flora (V2) pixelsabove, but designed for use withbreadboards rather than sewing.Sold in packs of 4. Use in breadboardsrequires soldering on header pins, soldseparately (http://adafru.it/392).Neo Pixel Stickhttp://www.adafruit.com/products/1426 (http://adafru.it/1426)This features 8 NeoPixel LEDs on a rigidcircuit board packed even more tightlythan the flex strips. There are solderpads on the back for connecting wires orbreadboard pins (not included). Can bechained end-to-end to create a longerstick.Neo Matrix 8x8: 64 RGB LED PixelMatrixhttp://www.adafruit.com/products/1487 (http://adafru.it/1487)An 8-by-8 matrix of NeoPixel LEDs (64LEDs total), all controlled from a singlemicrocontroller pin. Can be chained, andthe LED spacing and board size aredesigned for seamless tiling.A substantial power supply isrecommended. At peak brightness (allLEDs on, brightest white) the matrix candraw just over 3.5 Amps at 5 Volts. Mixedcolors and lower brightness settings willuse proportionally less power.Neo Pixel Shield fo r Arduino : 40RGB LED Pixel Matrixhttp://www.adafruit.com/products/1430 (http://adafru.it/1430)A smaller 5x8 matrix designed to plugdirectly atop an Arduino board (but canalso be tiled separately if desired).If the overall brightness is carefullylimited, the shield can be directlypowered from the Arduino. For mostsituations, connecting an external 5Vpower supply is recommended. At peakbrightness, the matrix can draw about 2.4Amps at 5 Volts (the Arduino can onlysupply about 500 milliamps). Adafruit xel-uberguidePage 7 of 28

Neo Pixel Ringhttp://www.adafruit.com/products/1463 (http://adafru.it/1463)16 NeoPixel LEDs in a circulararrangement with the center cut out.Perfect for jewelry, spectacles, rotaryknob feedback or whatever else yourimagination can dream up.Outside diameter is 1.75 inches (44.5millimeters). Can be chained. Each ringmay require up to 1 Amp at maximumbrightness.WS2812 5050 RGB LEDhttp://www.adafruit.com/products/1379 (http://adafru.it/1379)For advanced users who want to developtheir own circuits and device formfactors, this is the “raw” NeoPixel LEDwith integrated driver.Sold in packs of 10.This is a surface-mount device, notrecommended for novice soldering. Forthrough-hole use, consider BreadboardFriendly NeoPixels (http://adafru.it/1312).WS2811 LED Driver Chiphttp://www.adafruit.com/products/1378 (http://adafru.it/1378)The heart of “V1” Flora NeoPixels, this isthe PWM driver independent of the RGBLED, so you can use other LED formfactors or colors. The protocol is slightlydifferent from most other NeoPixeldevices and they’re not directlyinterchangeable, but a project can mixboth types if they’re on separatemicrocontroller pins. TheAdafruit NeoPixellibrary (http://adafru.it/aZU) supportsboth types.Sold in packs of 10. Adafruit xel-uberguidePage 8 of 28

Arduino LibraryControlling NeoPixels “from scratch” is quite a challenge, so we provide a library letting youfocus on the fun and interesting bits. The library works with most mainstream Arduino boardsand derivatives: Uno, Mega, Leonardo, Micro, Adafruit Flora, etc. — most anything with an AtmelAVR 8-bit processor from 8 to 16 MHz — and also works with the Arduino Due and all varietiesof the PJRC Teensy boards.Because processor-specific assembly language is used, this library does not work onNetduino, ChipKIT or other advanced “Arduino-like” boards. Others may have written code andlibraries for such boards, but we can’t provide technical support for any bugs or trouble there;that’s frontier stuff. Some of this is covered in the “Advanced Coding” section.Installation of the library is as follows:1. Visit the Adafruit NeoPixel library page (http://adafru.it/aZU) at Github.com.2. Select th

01.01.2014 · Adafruit NeoPixels are Available in the Following Products: NeoPixel Digital RGB LED Weatherproof Strip: 30 LEDs per meter on a white backing strip. http://www.adafruit.com/products/1376 (http://adafru.it