Convert Figma logo to code with AI

Makuna logoNeoPixelBus

An Arduino NeoPixel support library supporting a large variety of individually addressable LEDs. Please refer to the Wiki for more details. Please use the GitHub Discussions to ask questions as the GitHub Issues feature is used for bug tracking.

1,172
257
1,172
41

Top Related Projects

6,405

The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.

Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)

WS2812 FX Library for Arduino and ESP8266

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.

Quick Overview

The Makuna/NeoPixelBus is a C++ library for controlling various types of addressable LED strips, such as WS2811, WS2812, and SK6812. It provides a simple and efficient way to control these LED strips from Arduino, ESP8266, and ESP32 boards.

Pros

  • Cross-platform compatibility: The library supports a wide range of microcontroller platforms, including Arduino, ESP8266, and ESP32.
  • Efficient and optimized: The library is designed to be efficient and optimized for performance, making it suitable for real-time LED control applications.
  • Flexible and customizable: The library offers a range of configuration options and supports various LED strip types and color models.
  • Active development and community support: The project is actively maintained, and the community provides support and contributions.

Cons

  • Limited documentation: The project's documentation could be more comprehensive, which may make it challenging for new users to get started.
  • Dependency on external libraries: The library depends on external libraries, such as the Arduino core library, which may add complexity to the project setup.
  • Limited support for advanced features: While the library provides basic LED control functionality, it may not offer advanced features or customization options that some users might require.
  • Potential performance issues on resource-constrained platforms: On some low-power microcontrollers, the library's performance may be a concern, especially for large LED strip installations.

Code Examples

Here are a few code examples demonstrating the usage of the NeoPixelBus library:

  1. Initializing the LED strip and setting pixel colors:
#include <NeoPixelBus.h>

const uint16_t PixelCount = 60;
const uint8_t PixelPin = 2;

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);

void setup() {
  strip.Begin();
}

void loop() {
  strip.SetPixelColor(0, RgbColor(255, 0, 0));
  strip.SetPixelColor(1, RgbColor(0, 255, 0));
  strip.SetPixelColor(2, RgbColor(0, 0, 255));
  strip.Show();
  delay(1000);
}
  1. Animating the LED strip with a color gradient:
#include <NeoPixelBus.h>

const uint16_t PixelCount = 60;
const uint8_t PixelPin = 2;

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);

void setup() {
  strip.Begin();
}

void loop() {
  static uint16_t offset = 0;
  for (uint16_t i = 0; i < PixelCount; i++) {
    strip.SetPixelColor(i, HslColor(((i * 360) / PixelCount + offset) / 360.0f, 1.0f, 0.5f));
  }
  strip.Show();
  offset++;
  delay(10);
}
  1. Using the HSV color model and applying a color wheel effect:
#include <NeoPixelBus.h>

const uint16_t PixelCount = 60;
const uint8_t PixelPin = 2;

NeoPixelBus<NeoHsvFeature, Neo800KbpsMethod> strip(PixelCount, PixelPin);

void setup() {
  strip.Begin();
}

void loop() {
  static uint16_t hue = 0;
  for (uint16_t i = 0; i < PixelCount; i++) {
    strip.SetPixelColor(i, HsvColor(hue + (i * 65536L / PixelCount), 255, 255));
  }
  strip.Show();
  hue++;
  delay(10);
}

Getting Started

To get started with the NeoPixelBus library,

Competitor Comparisons

6,405

The FastLED library for colored LED animation on Arduino. Please direct questions/requests for help to the FastLED Reddit community: http://fastled.io/r We'd like to use github "issues" just for tracking library bugs / enhancements.

Pros of FastLED

  • More extensive color manipulation and effects library
  • Better support for a wider range of LED types
  • Larger community and more extensive documentation

Cons of FastLED

  • Higher memory usage, especially for small projects
  • Can be more complex to set up for beginners
  • Less flexible in terms of pin assignments on some microcontrollers

Code Comparison

NeoPixelBus example:

#include <NeoPixelBus.h>
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(60, 2);
strip.Begin();
strip.SetPixelColor(0, RgbColor(255, 0, 0));
strip.Show();

FastLED example:

#include <FastLED.h>
CRGB leds[60];
FastLED.addLeds<WS2812B, 2, GRB>(leds, 60);
leds[0] = CRGB::Red;
FastLED.show();

Both libraries offer efficient ways to control LED strips, but FastLED provides more advanced features for complex lighting projects, while NeoPixelBus offers simpler setup and potentially lower resource usage for basic applications. The choice between them depends on the specific requirements of your project and your familiarity with each library's syntax and features.

Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)

Pros of Adafruit_NeoPixel

  • Simpler API, easier for beginners to use
  • Extensive documentation and tutorials available
  • Wide community support and compatibility with Adafruit products

Cons of Adafruit_NeoPixel

  • Limited color space support (primarily RGB)
  • Less efficient in terms of memory usage and performance
  • Fewer advanced features and customization options

Code Comparison

NeoPixelBus:

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(pixelCount, pixelPin);
strip.Begin();
strip.SetPixelColor(0, RgbColor(255, 0, 0));
strip.Show();

Adafruit_NeoPixel:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(pixelCount, pixelPin, NEO_GRB + NEO_KHZ800);
strip.begin();
strip.setPixelColor(0, strip.Color(255, 0, 0));
strip.show();

NeoPixelBus offers more flexibility in color space and timing methods, while Adafruit_NeoPixel provides a simpler interface. NeoPixelBus also supports various color orders and has better performance, especially for larger LED counts. However, Adafruit_NeoPixel is more beginner-friendly and has extensive documentation. Choose based on your project requirements and expertise level.

WS2812 FX Library for Arduino and ESP8266

Pros of WS2812FX

  • Includes a wide variety of pre-built effects and animations
  • Easy to use API for controlling LED strips
  • Supports multiple LED strips simultaneously

Cons of WS2812FX

  • Less flexible for custom effects compared to NeoPixelBus
  • May have higher memory usage due to built-in effects
  • Limited support for different LED types

Code Comparison

WS2812FX:

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
ws2812fx.init();
ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
ws2812fx.start();

NeoPixelBus:

NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(LED_COUNT, LED_PIN);
strip.Begin();
strip.ClearTo(RgbColor(0, 0, 0));
strip.Show();

The WS2812FX library provides a higher-level abstraction with built-in effects, making it easier to create animations quickly. NeoPixelBus offers more low-level control, allowing for greater customization but requiring more code for complex effects.

WS2812FX is ideal for projects needing quick implementation of various effects, while NeoPixelBus is better suited for projects requiring fine-grained control over LED behavior and support for a wider range of LED types.

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.

Pros of blynk-library

  • Provides a complete IoT platform with cloud services and mobile app integration
  • Offers a wide range of widgets for creating custom interfaces
  • Supports multiple hardware platforms and connectivity options

Cons of blynk-library

  • Requires an internet connection and relies on external servers
  • Limited customization options for advanced users
  • Potential privacy concerns due to cloud-based nature

Code Comparison

NeoPixelBus:

#include <NeoPixelBus.h>
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(16);
strip.Begin();
strip.SetPixelColor(0, RgbColor(255, 0, 0));
strip.Show();

blynk-library:

#include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken";
Blynk.begin(auth, ssid, pass);
BLYNK_WRITE(V1) {
  int pinValue = param.asInt();
}

The NeoPixelBus library focuses on controlling LED strips with various color formats and timings. It provides low-level control and is optimized for performance. The blynk-library, on the other hand, offers a higher-level abstraction for IoT projects, including remote control and monitoring capabilities through its cloud platform and mobile app.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

NeoPixelBus

Donate

Arduino NeoPixel library

A library to control one wire protocol RGB, RGBW, and RGBWW leds like APA106, SK6812, WS2811, WS2812 and WS2813 that are commonly refered to as NeoPixels and two wire protocol RGB like Lpd8806, APA102 and SK9822 commonly refered to as DotStars. Supports most Arduino platforms.

For quick questions and support:

For bugs, make sure there isn't an active issue and then create one.

Documentation

See Wiki

Installing This Library (preferred, you just want to use it)

Open the Library Manager and search for "NeoPixelBus by Makuna" and install

Installing This Library From GitHub (advanced, you want to contribute)

Create a directory in your Arduino\Library folder named "NeoPixelBus" Clone (Git) this project into that folder.
It should now show up in the import list when you restart Arduino IDE.