Top Related Projects
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.
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
- 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();
}
- Changing animation mode and color:
ws2812fx.setMode(FX_MODE_STATIC);
ws2812fx.setColor(RED);
- 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
- Install the WS2812FX library through the Arduino Library Manager or download it from GitHub.
- Include the library in your sketch:
#include <WS2812FX.h>
- Create a WS2812FX object:
WS2812FX ws2812fx = WS2812FX(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
- In
setup()
, initialize the object:ws2812fx.init();
- Set brightness, speed, and mode:
ws2812fx.setBrightness(100); ws2812fx.setSpeed(1000); ws2812fx.setMode(FX_MODE_RAINBOW_CYCLE);
- Start the animation:
ws2812fx.start();
- In
loop()
, call the service function:ws2812fx.service();
Competitor Comparisons
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.
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 designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
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
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
- Static - No blinking. Just plain old static light.
- Blink - Normal blinking. 50% on/off time.
- Breath - Does the "standby-breathing" of well known i-Devices. Fixed Speed.
- Color Wipe - Lights all LEDs after each other up. Then turns them in that order off. Repeat.
- Color Wipe Inverse - Same as Color Wipe, except swaps on/off colors.
- Color Wipe Reverse - Lights all LEDs after each other up. Then turns them in reverse order off. Repeat.
- Color Wipe Reverse Inverse - Same as Color Wipe Reverse, except swaps on/off colors.
- Color Wipe Random - Turns all LEDs after each other to a random color. Then starts over with another color.
- Random Color - Lights all LEDs in one random color up. Then switches them to the next random color.
- Single Dynamic - Lights every LED in a random color. Changes one random LED after the other to a random color.
- Multi Dynamic - Lights every LED in a random color. Changes all LED at the same time to new random colors.
- Rainbow - Cycles all LEDs at once through a rainbow.
- Rainbow Cycle - Cycles a rainbow over the entire string of LEDs.
- Scan - Runs a single pixel back and forth.
- Dual Scan - Runs two pixel back and forth in opposite directions.
- Fade - Fades the LEDs on and (almost) off again.
- Theater Chase - Theatre-style crawling lights. Inspired by the Adafruit examples.
- Theater Chase Rainbow - Theatre-style crawling lights with rainbow effect. Inspired by the Adafruit examples.
- Running Lights - Running lights effect with smooth sine transition.
- Twinkle - Blink several LEDs on, reset, repeat.
- Twinkle Random - Blink several LEDs in random colors on, reset, repeat.
- Twinkle Fade - Blink several LEDs on, fading out.
- Twinkle Fade Random - Blink several LEDs in random colors on, fading out.
- Sparkle - Blinks one LED at a time.
- Flash Sparkle - Lights all LEDs in the selected color. Flashes single white pixels randomly.
- Hyper Sparkle - Like flash sparkle. With more flash.
- Strobe - Classic Strobe effect.
- Strobe Rainbow - Classic Strobe effect. Cycling through the rainbow.
- Multi Strobe - Strobe effect with different strobe count and pause, controlled by speed setting.
- Blink Rainbow - Classic Blink effect. Cycling through the rainbow.
- Chase White - Color running on white.
- Chase Color - White running on color.
- Chase Random - White running followed by random color.
- Chase Rainbow - White running on rainbow.
- Chase Flash - White flashes running on color.
- Chase Flash Random - White flashes running, followed by random color.
- Chase Rainbow White - Rainbow running on white.
- Chase Blackout - Black running on color.
- Chase Blackout Rainbow - Black running on rainbow.
- Color Sweep Random - Random color introduced alternating from start and end of strip.
- Running Color - Alternating color/white pixels running.
- Running Red Blue - Alternating red/blue pixels running.
- Running Random - Random colored pixels running.
- Larson Scanner - K.I.T.T.
- Comet - Firing comets from one end.
- Fireworks - Firework sparks.
- Fireworks Random - Random colored firework sparks.
- Merry Christmas - Alternating green/red pixels running.
- Fire Flicker - Fire flickering effect. Like in harsh wind.
- Fire Flicker (soft) - Fire flickering effect. Runs slower/softer.
- Fire Flicker (intense) - Fire flickering effect. More range of color.
- Circus Combustus - Alternating white/red/black pixels running.
- Halloween - Alternating orange/purple pixels running.
- Bicolor Chase - Two LEDs running on a background color.
- Tricolor Chase - Alternating three color pixels running.
- TwinkleFOX - Lights fading in and out randomly.
- thru 63. Custom - Up to eight user created custom effects.
Projects using WS2812FX
- Smart Home project by renat2985 using the ESP8266. Including a nice webinterface in the demo video!
- WiFi LED Star by kitesurfer1404
- McLighting by toblum is a multi-client lighting gadget for ESP8266
Top Related Projects
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.
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.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot