WS2812 RGB LED Strip Controller for Arduino
- Features
- Changelog
- Materials
- Dependencies
- Schematic
- Setup
- Quick Start
- Documentation
- Constructor
Pixels(CRGB leds_array[], byte num_leds)
- Description - Parameters- Members
void chase(word delay_ms=20, CRGB color=randomColor(), byte segment_length=1, Direction direction=RIGHT)
- Description - Parametersvoid fillStrip(word delay_ms=25, CRGB color=randomColor())
- Description - Parametersvoid fillFromMiddle(word delay_ms=60, CRGB color=randomColor())
- Description - Parametersvoid fillFromSides(word delay_ms=60, CRGB color=randomColor())
- Description - Parametersvoid randomFill(word delay_ms=150, CRGB color=randomColor())
- Description - Parametersvoid wipe(word delay_ms=50, CRGB color=randomColor())
- Description - Parametersvoid altColors(word delay_ms=125, CRGB first_color=randomColor(), CRGB second_color=randomColor())
- Description - Parametersvoid bounce(word delay_ms=30, byte segment_length=1, CRGB color=randomColor())
- Description - Parametersvoid rgbFade(word delay_ms=3)
- Description - Parametersvoid rainbow(word delay_ms=20, byte iterations=1)
- Description - Parametersvoid rainbowChase(word delay_ms=50)
- Description - Parametersvoid rainbowCycle(word delay_ms=100)
- Description - Parametersvoid sparkle(word delay_ms=10, CRGB color=CRGB::White)
- Description - Parametersvoid meteor(word delay_ms=50, byte length=5, boolean random_decay=true, byte decay_amount=64, CRGB color=randomColor())
- Description - Parametersstatic CRGB randomColor()
- Description - Returnsvoid clear()
- Descriptionvoid setStrip(CRGB color)
- Description - Parameters
- Additional Resources
- Two buttons for control
- Current animation resumes even after power cycle
- Use the library by itself or with the controller sketch
- Built with FastLED library
Release | Changes | Date |
---|---|---|
v1.0 |
|
6/10/2020 |
- Any Arduino-compatible board(ex: Arduino Pro Mini, SparkFun Pro Micro)
- WS2812b Individually Addressable RGB LEDs
- 270 ohm resistor
- 1000 ÎĽF capacitor
- 5V Power Supply(The amperage depends on your project. Each LED draws about 60mA @ full brightness/completely white)
- FTDI USB to Serial Converter (for programming your board if it doesn't have USB support, such as for the Pro Mini)
- FastLED library(from here)
- EEPROM library(should already be included with Arduino IDE)
possible setup on a breadboard
-
Set up a circuit like above
-
Download Pixels from releases tab
-
Edit
Pixels.ino
- Edit the macro definitions at the top of
Pixels.ino
for your specific setup
#define NUM_LEDS 30 // <- the number of leds in your strip #define PIN 10 // <- the pin on your board you want to use for data #define NEXT_ANIMATION_PIN 2 // <- the pin your next animation button is attached to #define ON_OFF_PIN 3 // <- the pin your on/off button is attached to
- Edit the macro definitions at the top of
-
Upload
Pixels.ino
to your board -
Power up your board and LED strip
-
Enjoy!
if you want to use Pixels by itself
void setup() {
// init Pixels
CRGB leds[NUM_LEDS];
FastLED.addLeds<NEOPIXEL, PIN>(leds, NUM_LEDS);
Pixels pixels(leds, NUM_LEDS);
pixels.chase(20, CRGB(150, 0, 0), 5, LEFT);
...
}
void loop() {
}
Initialize a Pixels object
- leds_array - (CRGB[]) CRGB array declared with a size of
num_leds
- num_leds - (byte) number of LEDS on strip
void chase(word delay_ms=20, CRGB color=randomColor(), byte segment_length=1, Direction direction=RIGHT)
Chase animation going left or right
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
- segment_length - (byte) length of segment
- direction - (Direction) direction of animation
Fill strip animation starting from the first LED
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
Fill strip animation starting from the middle of the strip
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
Fill strip animation starting from both ends
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
Random filling of strip one LED at a time
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
Color wipe animation across entire strip
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
Alternating colors every other LED on strip
- delay_ms - (word) delay in ms
- first_color - (CRGB) first RGB color for animation
- second_color - (CRGB) second RGB color for animation
Bouncing animation of one LED from left to right and back
- delay_ms - (word) delay in ms
- segment_length - (byte) length of segment
- color - (CRGB) RGB color for animation
Fade of RGB values on whole strip
- delay_ms - (word) delay in ms
Cycle of colors in rainbow over entire strip
- delay_ms - (word) delay in ms
- iterations - (byte) repetitions of animation
Rainbow chase animation
- delay_ms - (word) delay in ms
Cycle through rainbow hue spectrum over entire strip
- delay_ms - (word) delay in ms
Flashing random LEDs to create sparkling effect
- delay_ms - (word) delay in ms
- color - (CRGB) RGB color for animation
void meteor(word delay_ms=50, byte length=5, boolean random_decay=true, byte decay_amount=64, CRGB color=randomColor())
Meteor rain animation
- delay_ms - (word) delay in ms
- length - (byte) length of meteor
- random_decay - (boolean) allow meteor trail or just keep as solid color
- decay_amount - (byte) how much trail should decay expressed as fraction of 256. ex: 25% = 64/256
- color - (CRGB) RGB color for animation
Generate a random CRGB color
- (CRGB) - random color
Clear entire strip(set each LED to black)
Set entire strip to a color
- color - (CRGB) RGB color to set strip to