Arduino Controlled WS2811 LED Strip DIY Project

by malisa55 in Circuits > Arduino

10 Views, 1 Favorites, 0 Comments

Arduino Controlled WS2811 LED Strip DIY Project

ws2811-1.jpg

First, connect the Arduino's VIN pin to the +12V terminal of your power supply.

Then, hook up the Arduino GND to the negative (–) terminal of the power supply.

Now, take the data pin you’re using in your code (like D7 or D8) and connect it to the DIN pin of the WS2811 LED strip.

Connect the red (positive) wire of the LED strip directly to the 12V power supply’s + terminal.

Finally, make sure both the GND near the Arduino’s digital pins and the LED strip’s GND wire are connected to the 12V power supply’s – terminal.

Supplies

Arduino Wiring

ws2811-2.jpg

The control board draws less than 500mA, so it doesn’t need much power.

Never connect a power supply directly to the 3.3V or 5V pins—those are output only. To safely power the board, use the DC jack or connect to VIN and GND.

The LED strip uses 12V DC, while the control board works best with 3.3V to 9V DC. So yes, power them separately.

As for wiring: whether you're using addressable RGB, RGBW, or RGBWW strips, the wiring stays the same. But heads up—their control code is different, so you can't just swap it.

For best performance, keep the pixel count reasonable:

  1. Up to 500 pixels for RGB
  2. 375 for RGBW
  3. 300 for RGBWW
  4. Going over these limits? It’ll still work, but you might notice a slower refresh rate.


Connect Arduino Power Supply and WS2811 LED Strip

ws2811-1.jpg

First, connect the Arduino's VIN pin to the +12V terminal of your power supply.

Then, hook up the Arduino GND to the negative (–) terminal of the power supply.

Now, take the data pin you’re using in your code (like D7 or D8) and connect it to the DIN pin of the WS2811 LED strip.

Connect the red (positive) wire of the LED strip directly to the 12V power supply’s + terminal.

Finally, make sure both the GND near the Arduino’s digital pins and the LED strip’s GND wire are connected to the 12V power supply’s – terminal.

Code

#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);

}

Texting

How to Control WS2811 Addressable LED Strips with Arduino