Convert Figma logo to code with AI

kitesurfer1404 logoWS2812FX

WS2812 FX Library for Arduino and ESP8266

1,581
344
1,581
4

Top Related Projects

6,353

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.)

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.

14,554

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!

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

Quick Overview

WS2812FX is a feature-rich library for controlling WS2812 LED strips (NeoPixels) with Arduino. It provides a wide range of built-in animations and effects, along with the ability to create custom ones. The library is designed to be easy to use while offering advanced functionality for more complex projects.

Pros

  • Extensive collection of pre-built animations and effects
  • Easy to use API for controlling LED strips
  • Supports multiple LED strips simultaneously
  • Customizable and expandable with user-defined effects

Cons

  • Limited to WS2812 LED strips and compatible variants
  • Requires more memory compared to simpler LED control libraries
  • May have performance limitations on lower-end Arduino boards
  • Documentation could be more comprehensive for advanced usage

Code Examples

  1. Basic usage to set up and run an animation:
#include <WS2812FX.h>

#define LED_COUNT 30
#define LED_PIN 5

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  ws2812fx.init();
  ws2812fx.setBrightness(100);
  ws2812fx.setSpeed(1000);
  ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
  ws2812fx.start();
}

void loop() {
  ws2812fx.service();
}
  1. Changing animation mode and color:
ws2812fx.setMode(FX_MODE_STATIC);
ws2812fx.setColor(RED);
  1. Creating a custom effect:
uint16_t myCustomEffect(void) {
  // Custom effect logic here
  return 50; // Return the delay until the next update
}

void setup() {
  // ... other setup code ...
  uint32_t customEffectId = ws2812fx.setCustomMode(F("My Custom Effect"), myCustomEffect);
  ws2812fx.setMode(customEffectId);
}

Getting Started

  1. Install the WS2812FX library through the Arduino Library Manager or download it from GitHub.
  2. Include the library in your sketch: #include <WS2812FX.h>
  3. Create a WS2812FX object: WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
  4. In setup(), initialize the object: ws2812fx.init();
  5. Set brightness, speed, and mode: ws2812fx.setBrightness(100); ws2812fx.setSpeed(1000); ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
  6. Start the animation: ws2812fx.start();
  7. In loop(), call the service function: ws2812fx.service();

Competitor Comparisons

6,353

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 comprehensive and feature-rich library for LED control
  • Supports a wider range of LED types and chipsets
  • Highly optimized for performance and efficiency

Cons of FastLED

  • Steeper learning curve due to its complexity
  • May be overkill for simple projects or beginners

Code Comparison

FastLED:

#include <FastLED.h>
#define NUM_LEDS 60
CRGB leds[NUM_LEDS];
void setup() {
  FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
}

WS2812FX:

#include <WS2812FX.h>
#define LED_COUNT 60
#define LED_PIN 6
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  ws2812fx.init();
  ws2812fx.start();
}

FastLED offers more low-level control and flexibility, while WS2812FX provides a higher-level abstraction with pre-built effects. FastLED is better suited for advanced users and complex projects, whereas WS2812FX is more accessible for beginners and quick implementations of common lighting effects.

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

Pros of Adafruit_NeoPixel

  • Simpler API, easier for beginners to get started
  • Extensive documentation and community support
  • Direct hardware control for potentially faster performance

Cons of Adafruit_NeoPixel

  • Limited built-in animation effects
  • Requires more manual coding for complex patterns
  • Less flexible for creating custom animations

Code Comparison

Adafruit_NeoPixel:

#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel strip(60, PIN, NEO_GRB + NEO_KHZ800);
strip.begin();
strip.setPixelColor(i, red, green, blue);
strip.show();

WS2812FX:

#include <WS2812FX.h>
WS2812FX ws2812fx = WS2812FX(60, PIN, NEO_GRB + NEO_KHZ800);
ws2812fx.init();
ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
ws2812fx.start();
ws2812fx.service();

The Adafruit_NeoPixel library provides a more low-level approach, giving direct control over individual LED colors. This can be beneficial for simple projects or when precise control is needed. However, it requires more manual coding for animations.

WS2812FX, on the other hand, offers a higher-level API with built-in effects and easier animation management. It's more suitable for complex projects requiring various pre-built effects or custom animations. The trade-off is a slightly more complex setup and potentially less direct hardware control.

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.

Pros of NeoPixelBus

  • More efficient memory usage and faster execution
  • Support for a wider range of LED types and color spaces
  • Better handling of timing-critical operations

Cons of NeoPixelBus

  • Steeper learning curve due to more complex API
  • Fewer built-in effects and animations compared to WS2812FX

Code Comparison

WS2812FX:

#include <WS2812FX.h>
#define LED_COUNT 30
#define LED_PIN 5
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
ws2812fx.start();

NeoPixelBus:

#include <NeoPixelBus.h>
#define LED_COUNT 30
#define LED_PIN 5
NeoPixelBus<NeoGrbFeature, Neo800KbpsMethod> strip(LED_COUNT, LED_PIN);
strip.Begin();
strip.ClearTo(RgbColor(0, 0, 0));
strip.Show();

NeoPixelBus offers more granular control over LED operations but requires more setup code. WS2812FX provides a simpler interface for quick implementations of common effects. NeoPixelBus is better suited for advanced projects requiring precise color control and timing, while WS2812FX is ideal for rapid prototyping and simpler LED animations.

14,554

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!

Pros of WLED

  • More comprehensive feature set, including advanced effects and sound reactivity
  • User-friendly web interface for easy control and configuration
  • Active development and community support

Cons of WLED

  • Higher resource requirements, potentially less suitable for low-power devices
  • Steeper learning curve for customization due to more complex codebase

Code Comparison

WLED:

void loop() {
  WLED::instance().loop();
}

WS2812FX:

void loop() {
  ws2812fx.service();
}

Summary

WLED offers a more feature-rich and user-friendly experience, with a web interface and advanced effects. However, it may require more resources and have a steeper learning curve for customization. WS2812FX is simpler and potentially more suitable for low-power devices but lacks some of the advanced features found in WLED. The code comparison shows that WLED uses a singleton instance for its main loop, while WS2812FX calls a service method directly. Both libraries provide easy-to-use interfaces for controlling LED strips, but WLED offers a more comprehensive solution for complex lighting projects.

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

Pros of Blynk Library

  • Provides a comprehensive IoT platform for remote device control and monitoring
  • Offers a user-friendly mobile app interface for easy interaction with connected devices
  • Supports a wide range of hardware platforms and connectivity options

Cons of Blynk Library

  • Requires an internet connection and relies on cloud services for functionality
  • May have a steeper learning curve for beginners compared to WS2812FX
  • Limited to Blynk ecosystem, potentially restricting flexibility in project design

Code Comparison

WS2812FX:

#include <WS2812FX.h>
#define LED_COUNT 30
#define LED_PIN 5
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

Blynk Library:

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
char auth[] = "YourAuthToken";
Blynk.begin(auth, ssid, pass);

The WS2812FX library focuses on controlling LED strips with various effects, while the Blynk Library is designed for creating IoT applications with remote control capabilities. WS2812FX is more specialized for LED projects, whereas Blynk offers a broader range of IoT functionalities but requires additional setup and cloud connectivity.

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

WS2812FX library

WS2812FX - More Blinken for your LEDs!

This library features a variety of blinken effects for the WS2811/WS2812/NeoPixel LEDs. It is meant to be a drop-in replacement for the Adafruit NeoPixel library with additional features.

Features

  • 55 different effects. And counting.
  • Tested on Arduino Uno/Micro/Nano/Leonardo and ESP8266/ESP32.
  • All effects with printable names - easy to use in user interfaces.
  • FX, speed and brightness controllable on the fly.
  • Ready for sound-to-light (see external trigger example)

Download, Install and Example

arduino-library-badge

You can search for WS2812FX in the Arduino IDE Library Manager or install the latest (or development) version manually:

  • Install the famous Adafruit NeoPixel library (v1.1.7 or newer)
  • Download this repository.
  • Extract to your Arduino libraries directory.
  • Open Arduino IDE.
  • Now you can choose File > Examples > WS2812FX > ...

See examples for basic usage.

In it's most simple form, here's the code to get you started!

#include <WS2812FX.h>

#define LED_COUNT 30
#define LED_PIN 12

WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  ws2812fx.init();
  ws2812fx.setBrightness(100);
  ws2812fx.setSpeed(200);
  ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
  ws2812fx.start();
}

void loop() {
  ws2812fx.service();
}

More complex effects can be created by dividing your string of LEDs into segments (up to ten) and programming each segment independently. Use the setSegment() function to program each segment's mode, color, speed and direction (normal or reverse):

  • setSegment(segment index, start LED, stop LED, mode, color, speed, reverse);

Note, some effects make use of more than one color (up to three) and are programmed by specifying an array of colors:

  • setSegment(segment index, start LED, stop LED, mode, colors[], speed, reverse);
// divide the string of LEDs into two independent segments
uint32_t colors[] = {RED, GREEN};
ws2812fx.setSegment(0, 0,           (LED_COUNT/2)-1, FX_MODE_BLINK, colors, 1000, false);
ws2812fx.setSegment(1, LED_COUNT/2, LED_COUNT-1,     FX_MODE_BLINK, COLORS(ORANGE, PURPLE), 1000, false);

Effects

  1. Static - No blinking. Just plain old static light.
  2. Blink - Normal blinking. 50% on/off time.
  3. Breath - Does the "standby-breathing" of well known i-Devices. Fixed Speed.
  4. Color Wipe - Lights all LEDs after each other up. Then turns them in that order off. Repeat.
  5. Color Wipe Inverse - Same as Color Wipe, except swaps on/off colors.
  6. Color Wipe Reverse - Lights all LEDs after each other up. Then turns them in reverse order off. Repeat.
  7. Color Wipe Reverse Inverse - Same as Color Wipe Reverse, except swaps on/off colors.
  8. Color Wipe Random - Turns all LEDs after each other to a random color. Then starts over with another color.
  9. Random Color - Lights all LEDs in one random color up. Then switches them to the next random color.
  10. Single Dynamic - Lights every LED in a random color. Changes one random LED after the other to a random color.
  11. Multi Dynamic - Lights every LED in a random color. Changes all LED at the same time to new random colors.
  12. Rainbow - Cycles all LEDs at once through a rainbow.
  13. Rainbow Cycle - Cycles a rainbow over the entire string of LEDs.
  14. Scan - Runs a single pixel back and forth.
  15. Dual Scan - Runs two pixel back and forth in opposite directions.
  16. Fade - Fades the LEDs on and (almost) off again.
  17. Theater Chase - Theatre-style crawling lights. Inspired by the Adafruit examples.
  18. Theater Chase Rainbow - Theatre-style crawling lights with rainbow effect. Inspired by the Adafruit examples.
  19. Running Lights - Running lights effect with smooth sine transition.
  20. Twinkle - Blink several LEDs on, reset, repeat.
  21. Twinkle Random - Blink several LEDs in random colors on, reset, repeat.
  22. Twinkle Fade - Blink several LEDs on, fading out.
  23. Twinkle Fade Random - Blink several LEDs in random colors on, fading out.
  24. Sparkle - Blinks one LED at a time.
  25. Flash Sparkle - Lights all LEDs in the selected color. Flashes single white pixels randomly.
  26. Hyper Sparkle - Like flash sparkle. With more flash.
  27. Strobe - Classic Strobe effect.
  28. Strobe Rainbow - Classic Strobe effect. Cycling through the rainbow.
  29. Multi Strobe - Strobe effect with different strobe count and pause, controlled by speed setting.
  30. Blink Rainbow - Classic Blink effect. Cycling through the rainbow.
  31. Chase White - Color running on white.
  32. Chase Color - White running on color.
  33. Chase Random - White running followed by random color.
  34. Chase Rainbow - White running on rainbow.
  35. Chase Flash - White flashes running on color.
  36. Chase Flash Random - White flashes running, followed by random color.
  37. Chase Rainbow White - Rainbow running on white.
  38. Chase Blackout - Black running on color.
  39. Chase Blackout Rainbow - Black running on rainbow.
  40. Color Sweep Random - Random color introduced alternating from start and end of strip.
  41. Running Color - Alternating color/white pixels running.
  42. Running Red Blue - Alternating red/blue pixels running.
  43. Running Random - Random colored pixels running.
  44. Larson Scanner - K.I.T.T.
  45. Comet - Firing comets from one end.
  46. Fireworks - Firework sparks.
  47. Fireworks Random - Random colored firework sparks.
  48. Merry Christmas - Alternating green/red pixels running.
  49. Fire Flicker - Fire flickering effect. Like in harsh wind.
  50. Fire Flicker (soft) - Fire flickering effect. Runs slower/softer.
  51. Fire Flicker (intense) - Fire flickering effect. More range of color.
  52. Circus Combustus - Alternating white/red/black pixels running.
  53. Halloween - Alternating orange/purple pixels running.
  54. Bicolor Chase - Two LEDs running on a background color.
  55. Tricolor Chase - Alternating three color pixels running.
  56. TwinkleFOX - Lights fading in and out randomly.
  57. thru 63. Custom - Up to eight user created custom effects.

Projects using WS2812FX