NeoPixelBus object

Michael Miller edited this page Jun 11, 2018 · 33 revisions

See NeoPixelBus object API Reference for more details on the methods exposed.

This object will be used to set colors on the pixels. When constructed, a "feature" and a "method" object must be supplied to define which pixels you are using and how they are updated.

NeoPixelBus<FEATURE, METHOD> strip(pixelCount, pixelPin);

Below is an example to create one for most platforms. It will manage 16 pixels on pin 2. The pixels use the most common bus speed of 800Kbps, and the most common color order of Green, Red, and then Blue.

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(16, 2);

For the Esp8266 platforms, just omit the pin argument. This is due to hardware support that doesn't allow for selecting a pin.

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(16);

If you want to drive DotStars instead, use the following to create a bus that uses hardware SPI.

NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(32);

If you want to drive DotStars using software SPI, use the following to create a bus and provide the pins for clock and data lines.

NeoPixelBus<DotStarBgrFeature, DotStarMethod> strip(32, clockPin, dataPin);

Neo Features

These "feature" objects will be used to define what color order is used for the pixels and what color size (rgb, or rgbw). Currently there are only a few sizes and color formats.
If you do not see what you require, request it by creating an issue on GitHub.

NeoGrbFeature

A three element color in the order of Green, Red, and then Blue. The most common three element format. This is used for SK6812(grb), WS2811, and WS2812.

NeoGrbwFeature

A four element color in the order of Green, Red, Blue, and then White. A common four element format. This is used for SK6812rgbw pixels that have the separate white led in them.

NeoRgbFeature

A three element color in the order of Red, Green, and then Blue. Some older pixels used this. Also used by pixels that come in a traditional LED shape rather than the surface mount chip we often see today.

NeoRgbwFeature

A four element color in the order of Red, Green, Blue, and then White. A common four element format.

NeoBrgFeature

A three element color in the order of Blue, Red, and then Green.

NeoRbgFeature

A three element color in the order of Red, Blue, and then Green.

DotStar Features

These "feature" objects will be used to define what color order is used for the pixels and what color size (rgb, or rgbw). Currently there are only a few sizes and color formats. Used only with DotStar methods.

If you do not see what you require, request it by creating an issue on GitHub.

DotStarBgrFeature

A three element color in the order of Blue, Green, and then Red. Used only with DotStar methods.

DotStarLbgrFeature

Similar to the DotStarBgrFeature, except that it exposes the DotStar feature of a "luminance" value of 0-31. This will require the use of the RgbwColor object and the W element must be set to provide a luminance override on the pixel.
NOTE: Use of any luminance other than 31 will cause the update rate on the LEDs to be slowed, and thus not useful for POV displays.

DotStarGrbFeature

A three element color in the order of Green, Red, and then Blue. Used only with DotStar methods.

DotStarLgrbFeature

Similar to the DotStarGrbFeature, except that it exposes the DotStar feature of a "luminance" value of 0-31. This will require the use of the RgbwColor object and the W element must be set to provide a luminance override on the pixel. NOTE: Use of any luminance other than 31 will cause the update rate on the LEDs to be slowed, and thus not useful for POV displays.

Neo Methods

These platform methods will define "how" the pixels are updated. While primarily used to define how fast the data is sent out to support older pixels; for the Esp8266 it also defines the several methods required based on different form factors due to pin restrictions and exposed pins on the boards.

Neo800KbpsMethod

The Neo800KbpsMethod is the standard one to use with most Arduino boards.
It will automatically pick board specific defaults and this should be the one used unless otherwise needed.
On the Esp8266 using this Method has a Pin restriction. Please review NeoEsp8266Dma800KbpsMethod below for details.

Neo400KbpsMethod

Same as Neo800KbpsMethod but running at the older and slower data rate.

NeoWs2813Method

The NeoWs2813Method primarily expands the delay time to support these new chips. It is fully compatible with Ws2812 and some newer Ws2812b chips may require this method.
On the Esp8266 using this Method has a Pin restriction. Please review NeoEsp8266DmaWs2813Method below for details.

Platform specific

In most cases the above should be all the methods you need to use for all platforms. In a few cases, there are alternative methods that are useful to use on some platforms. Below are links to the platform specific methods.

DotStar Methods

These platform methods will define "how" the pixels are updated.

DotStarSpiMethod

This method should only be used with DotStar color features.
It will use the available hardware SPI support for the board you build with. The clock and data pins are not changeable for hardware support and thus the Pins argument is omitted.
The hardware pins on the board are often labeled as MOSI for data, and MSCLK or CLK for the clock.

DotStarMethod

This method should only be used with DotStar color features. It will use two provided pins for clock and data to implement a software SPI.