Get started with connecting a WS2813 RGB LED strip to an Arduino and making your own lighting effects—no prior experience required.
Here is a guide about WS2813 addressable LED strips with Arduino UNO wiring & Code.
1.Materials Required
Power Supply
Choose a DC5V power supply with AC110V or 220V input. This will power both the WS2813 LED strip and Arduino UNO using the 5V and GND connections. The open design helps keep the system cool for long-term use.
Arduino Board
The Arduino UNO R3 runs at 5V and uses the ATmega328P chip. It gets power from the 5V line of the power supply. The board comes with 14 digital I/O pins (6 have PWM) and 6 analog pins. It operates at 16 MHz and connects to your computer by USB. It’s a great choice for beginners.
WS2813 LED Strip
This 64 LEDs/m WS2813 LED strip is designed by Suntechlite. The model in the picture works at 5V DC. This strip has 64 RGB LEDs for each meter. Every LEDs is a pixel. So, there are 64 pixels per meter. The PCB width is 10mm. Each pixel can show any color. Data control uses a single-wire protocol. This strip is often used for decoration or creative projects.
When choosing addressable LED strips, it’s helpful to understand the differences between popular LED chips like WS2812B, WS2813, and WS2815. WS2812B is widely used and offers great color control, but if one LED fails, the rest after it may stop working. WS2813 improves on this with a backup data line—so even if one LED goes out, the rest will keep working normally. WS2815 works at 12V instead of 5V, so it’s easier to power longer LED strips. It also has a backup data wire. That means, if part of the strip has a problem, the rest will keep working.
Curious about which chip is right for your project? Read our WS2813 vs WS2812B comparison and WS2813 vs WS2815 comparison for more details.
Other Accessories
Wires: Needed to link the power supply, WS2813 strip, and Arduino.
Logic Level Shifter (Optional): A 3.3V level shifter helps protect the Arduino from voltage spikes.
2.Wiring Diagram
The diagram above shows how to connect your Arduino, WS2813 LED strip, and the power supply.
Note:
- The Arduino board uses less than 500mA of current.
- Never wire a power supply directly to the DC3.3V or 5V pins—they are output only.
- Use the DC jack or VIN+GND for power Arduino board.
- RGB, RGBW, and RGBWW strips connect the same way, but use different code.
- For best results, keep pixels under these maximums: 500 for addressable RGB LED strip, 375 for RGBW, 300 for RGBWW. More pixels slow the refresh rate.
3. Connection Diagram
Tips:
- Use a short, direct wire from Arduino to DATA IN on the LED strip.
- Make sure terminal connections on the power supply are tight.
- Always disconnect power before changing any wiring.
4. Code Upload
Below is an example code to control a WS2813 LED strip with Arduino. It includes different lighting effects.
If you need support or have questions, please contact us.
#include
#define LED_PIN 19 // LED strip data pin
#define NUM_LEDS 80 // Number of LEDs
#define BRIGHTNESS 128 // Initial brightness (0-255)
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB // Most WS2812 LEDs use GRB order
CRGB leds[NUM_LEDS];
// Effect mode enumeration
enum Effects {
EFFECT_FLOW, // Rainbow flow effect
EFFECT_BLINK, // Rainbow blink effect
EFFECT_MARQUEE, // Marquee effect
EFFECT_COUNT
};
uint8_t currentEffect = EFFECT_FLOW;
unsigned long lastEffectChange = 0;
unsigned long lastUpdate = 0;
void setup() {
delay(3000); // Startup safety delay
FastLED.addLeds(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
Serial.begin(115200);
}
// Rainbow flow effect
void flowEffect() {
static uint8_t hue = 0;
static uint8_t pos = 0;
// Gradually fade out all LEDs
fadeToBlackBy(leds, NUM_LEDS, 10);
// Set a colored point at the current position
leds[pos] = CHSV(hue, 255, 255);
// Move to the next position
pos = (pos + 1) % NUM_LEDS;
// Change hue
hue += 3;
FastLED.show();
delay(30);
}
// Rainbow blink effect
void blinkEffect() {
static bool lightsOn = false;
static uint8_t hue = 0;
if(lightsOn) {
// Fill the entire strip with a random color
fill_solid(leds, NUM_LEDS, CHSV(hue, 255, 255));
hue += 5;
} else {
// Turn all LEDs off
fill_solid(leds, NUM_LEDS, CRGB::Black);
}
lightsOn = !lightsOn;
FastLED.show();
delay(lightsOn ? 200 : 800); // On for 200ms, off for 800ms
}
// Marquee effect
void marqueeEffect() {
static uint8_t hue = 0;
static int position = 0;
static int tailLength = 15;
// Gradually fade out LEDs
fadeToBlackBy(leds, NUM_LEDS, 20);
// Create the marquee head
leds[position] = CHSV(hue, 255, 255);
// Create gradient tail
for(int i = 1; i 30000) {
currentEffect = (currentEffect + 1) % EFFECT_COUNT;
lastEffectChange = millis();
FastLED.clear();
FastLED.show();
}
// Run the current effect
switch(currentEffect) {
case EFFECT_FLOW: flowEffect(); break;
case EFFECT_BLINK: blinkEffect(); break;
case EFFECT_MARQUEE: marqueeEffect(); break;
}
// Optional: Brightness control
// adjustBrightness();
}
// Optional: Switch effects via serial commands
void serialEvent() {
while(Serial.available()) {
char c = Serial.read();
if(c >= '0' && c <= '2') {
currentEffect = c - '0';
FastLED.clear();
FastLED.show();
}
}
}
// Optional: Brightness adjustment function
void adjustBrightness() {
int potValue = analogRead(A0); // Connect potentiometer to A0
int newBrightness = map(potValue, 0, 1023, 0, 255);
FastLED.setBrightness(newBrightness);
}
5.Lighting Effect Demonstration
A video shows how an Arduino can control a WS2813 RGB LED strip to create various effects. Please use a suitable power supply, good wiring, and the right library for reliable results.
Following these steps, you can easily adjust lighting patterns on your WS2813 strip.
Need extra help or have questions? Contact us any time.