A powerful Arduino library for creating stunning LED effects with minimal code. VibeLED allows you to easily implement 50+ professional-quality lighting effects on regular LEDs or RGB LEDs with just a few lines of code.
- Features
- Installation
- Hardware Setup
- Quick Start
- API Reference
- Available Effects
- Advanced Usage
- Troubleshooting
- Performance Considerations
- Contributing
- License
- Credits
- Non-blocking timing: All effects use
millis()instead ofdelay()for smooth animations and responsive sketches - Support for both single-color and RGB LEDs: Works with standard LEDs, RGB LEDs, LED strips, and matrices
- 50+ built-in effects: Knight Rider, Cylon, Meteor, Fire, Waterfall, Rainbow, and many more
- Lightweight: Optimized for AVR-based Arduinos (UNO/Nano) with minimal memory footprint
- Simple API: Easy to use with minimal setup - create stunning effects with just a few lines of code
- Modular design: Easily extendable for custom effects
- Group control: Ability to address subsets of LEDs for complex patterns
- Customizable parameters: Adjust speed, brightness, colors, and more for each effect
- Compatible with popular LED libraries: Can be used alongside FastLED, Adafruit NeoPixel, etc.
- Open the Arduino IDE
- Go to Sketch > Include Library > Manage Libraries...
- In the Library Manager, search for "VibeLED"
- Click "Install" on the VibeLED library
- Download the ZIP file from the releases page
- In the Arduino IDE, go to Sketch > Include Library > Add .ZIP Library...
- Select the downloaded ZIP file
- Restart the Arduino IDE
Clone this repository directly into your Arduino libraries folder:
cd ~/Documents/Arduino/libraries
git clone https://github.com/skr-electronics-lab/VibeLED.gitFor single color LEDs, you'll need:
- Arduino board (UNO, Nano, Mega, etc.)
- LEDs (as many as you want to control)
- Resistors (220Ξ©-1kΞ©, depending on your LEDs)
- Jumper wires
- Breadboard (optional)
Arduino Pin ββββ Resistor ββββ LED ββββ GND
For multiple LEDs, you can connect them to different pins:
Arduino Pin 9 ββββ Resistor ββββ LED 1 ββββ GND
Arduino Pin 10 ββββ Resistor ββββ LED 2 ββββ GND
...
For many LEDs, consider using shift registers or LED driver ICs.
For RGB LEDs, you'll need:
- Arduino board
- RGB LEDs (common anode or common cathode)
- Resistors (220Ξ©-1kΞ© for each color channel)
- Jumper wires
- Breadboard (optional)
Arduino Pin 9 ββββ Resistor ββββ R pin of RGB LED
Arduino Pin 10 ββββ Resistor ββββ G pin of RGB LED
Arduino Pin 11 ββββ Resistor ββββ B pin of RGB LED
GND pin of RGB LED ββββ GND
For addressable LED strips (WS2812B, NeoPixels, etc.), you'll need:
- Arduino board
- Addressable LED strip
- Power supply (5V, with enough current for your LEDs)
- 300-500Ξ© resistor
- 1000ΞΌF capacitor
- Jumper wires
5V Power Supply ββββ LED Strip VCC
βββ Arduino 5V
Arduino GND ββββ LED Strip GND
βββ Power Supply GND
Arduino Pin (e.g., 6) ββββ 300-500Ξ© Resistor ββββ LED Strip Data In
#include <VibeLED.h>
// For single color LEDs
// VibeLED(pin, numLeds)
VibeLED leds(9, 10); // 10 LEDs connected to pin 9
// For RGB LEDs
// VibeLED(rPin, gPin, bPin, numLeds)
// VibeLED rgbLeds(9, 10, 11, 10); // 10 RGB LEDs with R, G, B on pins 9, 10, 11
void setup() {
leds.begin(); // Initialize the library
leds.setEffect(EFFECT_KNIGHT_RIDER); // Set the effect
leds.setDelay(100); // Set the effect speed (lower = faster)
}
void loop() {
leds.update(); // Update the effect animation (non-blocking)
// Your other code can run here without being blocked!
// Read sensors, check buttons, etc.
}// Set effect by enum
leds.setEffect(EFFECT_FIRE);
// Set effect with speed
leds.setEffect(EFFECT_METEOR, 50); // 50ms between updates
// Set effect with speed and color (RGB LEDs)
leds.setEffect(EFFECT_PULSE, 100, 255, 0, 0); // Red pulse
// Set effect with speed and Color object
Color purple(128, 0, 255);
leds.setEffect(EFFECT_BREATHE, 80, purple);
// Set effect by name (case-insensitive)
leds.setEffect("rainbow");
leds.setEffect("knight_rider");
leds.setEffect("fire");// Control a subset of LEDs
leds.setGroup(3, 7); // Only affect LEDs 3 through 7
leds.setEffect(EFFECT_BLINK);
// Create multiple effects on different sections
leds.setGroup(0, 4); // First 5 LEDs
leds.setEffect(EFFECT_FIRE);
leds.setGroup(5, 9); // Next 5 LEDs
leds.setEffect(EFFECT_WATER);
// Reset to control all LEDs
leds.resetGroup();
leds.setEffect(EFFECT_RAINBOW);// For single color LEDs
leds.setLED(0, true); // Turn on first LED
leds.setLED(1, false); // Turn off second LED
// For RGB LEDs
leds.setLED(0, 255, 0, 0); // Set first LED to red
leds.setLED(1, 0, 255, 0); // Set second LED to green
leds.setLED(2, 0, 0, 255); // Set third LED to blue
leds.setLED(3, 255, 255, 0); // Set fourth LED to yellow
// Using Color objects
Color teal(0, 128, 128);
leds.setLED(4, teal);// For single color LEDs
VibeLED(uint8_t pin, uint16_t numLeds = 1);
// For RGB LEDs
VibeLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, uint16_t numLeds = 1);| Method | Description |
|---|---|
void begin() |
Initialize the library. Must be called in setup(). |
void update() |
Update the effect animation. Must be called in loop(). |
void clear() |
Turn off all LEDs. |
| Method | Description |
|---|---|
void setBrightness(uint8_t brightness) |
Set the brightness level (0-255). |
void setDelay(uint16_t ms) |
Set the delay between effect updates in milliseconds. |
void setColor(uint8_t r, uint8_t g, uint8_t b) |
Set the primary color for effects. |
void setColor(Color color) |
Set the primary color using a Color object. |
| Method | Description |
|---|---|
void setEffect(EffectType effect) |
Set the current effect by enum. |
void setEffect(EffectType effect, uint16_t speed) |
Set effect with custom speed. |
void setEffect(EffectType effect, uint16_t speed, Color color) |
Set effect with speed and color. |
void setEffect(EffectType effect, uint16_t speed, uint8_t r, uint8_t g, uint8_t b) |
Set effect with speed and RGB color. |
void setEffect(EffectType effect, EffectParams params) |
Set effect with detailed parameters. |
void setEffect(String effectName) |
Set effect by name (case-insensitive). |
| Method | Description |
|---|---|
void setGroup(uint16_t startLed, uint16_t endLed) |
Set a group of LEDs to control. |
void resetGroup() |
Reset to control all LEDs. |
| Method | Description |
|---|---|
void setLED(uint16_t led, bool state) |
Set a single LED on or off (single color). |
void setLED(uint16_t led, uint8_t r, uint8_t g, uint8_t b) |
Set a single LED color (RGB). |
void setLED(uint16_t led, Color color) |
Set a single LED color using a Color object. |
VibeLED includes 50+ stunning effects, each with customizable parameters:
-
EFFECT_STATIC: Solid color
- Description: Displays a solid color on all LEDs
- Parameters: Color
-
EFFECT_BLINK: Simple on/off blinking
- Description: All LEDs blink on and off at a regular interval
- Parameters: Speed, Color
-
EFFECT_BREATHE: Smooth fade in and out
- Description: Smoothly fades LEDs in and out like breathing
- Parameters: Speed, Color
-
EFFECT_PULSE: Quick fade in, slow fade out
- Description: Quick fade in followed by a slower fade out
- Parameters: Speed, Color
-
EFFECT_FADE_IN: Fade from off to on
- Description: Gradually increases brightness from off to full
- Parameters: Speed, Color
-
EFFECT_FADE_OUT: Fade from on to off
- Description: Gradually decreases brightness from full to off
- Parameters: Speed, Color
-
EFFECT_KNIGHT_RIDER: Back and forth with trail
- Description: LED moves back and forth with a fading trail (like KITT from Knight Rider)
- Parameters: Speed, Color, Trail Length
-
EFFECT_CYLON: Similar to Knight Rider with different trail
- Description: Similar to Knight Rider but with a different trail effect (like Cylons from Battlestar Galactica)
- Parameters: Speed, Color, Trail Length
-
EFFECT_METEOR: Meteor falling effect
- Description: Simulates a meteor falling with a trail
- Parameters: Speed, Color, Meteor Size, Trail Length
-
EFFECT_CHASE: Single LED chasing
- Description: Single LED moving across the strip
- Parameters: Speed, Color
-
EFFECT_STACK: Fill and empty
- Description: LEDs fill up from one end, then empty
- Parameters: Speed, Color
-
EFFECT_SNAKE: Snake moving through the strip
- Description: A "snake" of lit LEDs moves through the strip
- Parameters: Speed, Color, Snake Length
-
EFFECT_WAVE: Sine wave pattern
- Description: Creates a sine wave pattern across the LEDs
- Parameters: Speed, Color, Wave Length
-
EFFECT_FIRE: Fire simulation
- Description: Realistic fire effect with flickering and color gradients
- Parameters: Speed, Intensity
-
EFFECT_WATERFALL: Cascading drops
- Description: Simulates water droplets falling
- Parameters: Speed, Color, Drop Frequency
-
EFFECT_RAIN: Rain simulation
- Description: Simulates raindrops falling
- Parameters: Speed, Color, Intensity
-
EFFECT_LIGHTNING: Lightning simulation
- Description: Random flashes simulating lightning
- Parameters: Flash Rate, Brightness
-
EFFECT_SPARKLE: Random twinkling
- Description: Random LEDs light up and turn off
- Parameters: Speed, Color, Density
-
EFFECT_TWINKLE: Gentle twinkling
- Description: Softer version of sparkle with fade in/out
- Parameters: Speed, Color, Density
-
EFFECT_TWINKLE_RANDOM: Random color twinkling
- Description: Twinkling with random colors
- Parameters: Speed, Density
-
EFFECT_TWINKLE_FADE: Twinkle with fade
- Description: Twinkling with smooth fade in/out
- Parameters: Speed, Color, Fade Rate
-
EFFECT_SPARKLE_FADE: Sparkle with fade
- Description: Sparkle effect with fading
- Parameters: Speed, Color, Fade Rate
-
EFFECT_HYPER_SPARKLE: Intense sparkling
- Description: More intense and frequent sparkling
- Parameters: Speed, Color, Density
-
EFFECT_RAINBOW: Rainbow cycle
- Description: Full rainbow cycle across all LEDs
- Parameters: Speed, Saturation, Brightness
-
EFFECT_COLOR_FADE: Fade between colors
- Description: Smooth transition between colors
- Parameters: Speed, Color1, Color2
-
EFFECT_GRADIENT: Color gradient
- Description: Creates a gradient across the LEDs
- Parameters: Color1, Color2
-
EFFECT_COLOR_WIPE: Color wipe in and out
- Description: Color "wipes" across the LEDs
- Parameters: Speed, Color
-
EFFECT_COLOR_SWEEP: Color sweep
- Description: Color sweeps across the LEDs
- Parameters: Speed, Color
- EFFECT_MARQUEE: Theater marquee effect
- EFFECT_BOUNCE: Bouncing with physics
- EFFECT_RANDOM_BLINK: Random blinking
- EFFECT_STROBE: Strobe light effect
- EFFECT_FIREWORK: Firework explosion
- EFFECT_RUNNING_LIGHTS: Running lights
- EFFECT_THEATER_CHASE: Theater chase
- EFFECT_SCAN: Scanning effect
- EFFECT_DUAL_SCAN: Dual scanning
- EFFECT_STROBE_RAINBOW: Rainbow strobe
- EFFECT_MULTI_STROBE: Multiple strobe
- EFFECT_CHASE_RAINBOW: Rainbow chase
- EFFECT_CHASE_BLACKOUT: Chase with blackout
- EFFECT_RUNNING_COLOR: Running color
- EFFECT_RUNNING_RED_BLUE: Running red and blue
- EFFECT_RUNNING_RANDOM: Running random colors
- EFFECT_LARSON_SCANNER: Larson scanner
- EFFECT_COMET: Comet effect
- EFFECT_FIREWORKS_RANDOM: Random fireworks
- EFFECT_MERRY_CHRISTMAS: Christmas pattern
- EFFECT_FIRE_FLICKER: Fire flickering
- EFFECT_FIRE_FLICKER_SOFT: Soft fire flickering
- EFFECT_FIRE_FLICKER_INTENSE: Intense fire flickering
- EFFECT_CIRCUS_COMBUSTUS: Circus combustus
- EFFECT_HALLOWEEN: Halloween pattern
- EFFECT_BICOLOR_CHASE: Bicolor chase
- EFFECT_TRICOLOR_CHASE: Tricolor chase
- EFFECT_ICU: ICU effect
You can create custom effects by extending the VibeLED class:
class MyVibeLED : public VibeLED {
public:
// Use the same constructors
MyVibeLED(uint8_t pin, uint16_t numLeds = 1) : VibeLED(pin, numLeds) {}
MyVibeLED(uint8_t rPin, uint8_t gPin, uint8_t bPin, uint16_t numLeds = 1) : VibeLED(rPin, gPin, bPin, numLeds) {}
// Add your custom effect
void setCustomEffect() {
setEffect(EFFECT_CUSTOM);
}
protected:
// Override the _updateEffect method to handle your custom effect
void _updateEffect() {
// Call the parent method first
VibeLED::_updateEffect();
// Add handling for your custom effect
if (_currentEffect == EFFECT_CUSTOM) {
// Implement your custom effect here
}
}
};For more control over effects, you can use the EffectParams structure:
EffectParams params;
params.speed = 100; // Update speed in milliseconds
params.brightness = 255; // Brightness (0-255)
params.color1 = Color(255, 0, 0); // Primary color (red)
params.color2 = Color(0, 0, 255); // Secondary color (blue)
params.color3 = Color(0, 255, 0); // Tertiary color (green)
params.option1 = 5; // Effect-specific option 1 (e.g., trail length)
params.option2 = 3; // Effect-specific option 2 (e.g., density)
leds.setEffect(EFFECT_KNIGHT_RIDER, params);VibeLED can be used alongside other libraries for enhanced functionality:
#include <VibeLED.h>
#include <FastLED.h> // For advanced LED strip control
#include <Button.h> // For button input
VibeLED leds(9, 10);
Button modeButton(2); // Button on pin 2
void setup() {
leds.begin();
modeButton.begin();
}
void loop() {
leds.update();
if (modeButton.pressed()) {
// Change effect when button is pressed
static uint8_t effectIndex = 0;
effectIndex = (effectIndex + 1) % 10; // Cycle through 10 effects
switch (effectIndex) {
case 0: leds.setEffect(EFFECT_RAINBOW); break;
case 1: leds.setEffect(EFFECT_FIRE); break;
// ... more effects
}
}
}| Issue | Possible Cause | Solution |
|---|---|---|
| LEDs not lighting up | Incorrect wiring | Double-check connections, ensure proper polarity |
| Insufficient power | Use an appropriate power supply for your LEDs | |
| Wrong pin numbers | Verify pin numbers in your code | |
| Flickering LEDs | Power supply issues | Use a more powerful power supply, add capacitors |
| Long wires | Shorten wires or use thicker gauge wire | |
| Arduino freezes | Too many LEDs | Reduce the number of LEDs or use a more powerful Arduino |
| Memory issues | Optimize your code, reduce variables |
-
Serial Output: Add serial debugging to your code
Serial.begin(9600); Serial.println("Effect: " + String(currentEffect));
-
Test with Fewer LEDs: Start with just a few LEDs to isolate issues
-
Check Power Requirements: Ensure your power supply can handle the current draw
- Each LED can draw up to 20mA at full brightness
- RGB LEDs can draw up to 60mA (20mA per channel)
- Each single-color LED requires 1 byte of RAM
- Each RGB LED requires 3 bytes of RAM
- Additional memory is used for effect calculations
- More complex effects require more CPU time
- Higher update rates (lower delay values) increase CPU usage
- Consider using a more powerful Arduino (e.g., Mega, ESP32) for many LEDs or complex effects
- Calculate your power requirements:
- Single LEDs: Number of LEDs Γ 20mA
- RGB LEDs: Number of LEDs Γ 60mA
- Use an appropriate power supply with at least 20% headroom
- For many LEDs, use external power and proper wiring techniques
Contributions to VibeLED are welcome! Here's how you can help:
- Report bugs: Open an issue describing the bug and how to reproduce it
- Suggest features: Open an issue describing the new feature
- Submit pull requests: Fork the repository, make your changes, and submit a pull request
Please follow these guidelines:
- Follow the existing code style
- Add comments to explain complex code
- Test your changes thoroughly
- Update documentation as needed
This library is released under the MIT License. See the LICENSE file for details.
- Created by SKR Electronics Lab, 2025
- Inspired by various LED effect libraries and techniques
- Special thanks to the Arduino community for their support and inspiration
- Visit our GitHub: https://github.com/skr-electronics-lab