Controlling WS2811 (12V) with Arduino

Hello,

I'm trying to control a WS2811 LED.

I have read and followed How can I connect my 12v ws2811 300 led strip

All 30 LED lightbulbs are solid lit except the first one that is not working. No dynamic light pattern is working. I have checked that all LEDs are working with the included driver.

The hardware I'm using:

/// @file    DemoReel100.ino
/// @brief   FastLED "100 lines of code" demo reel, showing off some effects
/// @example DemoReel100.ino

#include <FastLED.h>

FASTLED_USING_NAMESPACE

// FastLED "100-lines-of-code" demo reel, showing just a few 
// of the kinds of animation patterns you can quickly and easily 
// compose using FastLED.  
//
// This example also shows one easy way to define multiple 
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014


#define DATA_PIN    4
//#define CLK_PIN   4
#define LED_TYPE    WS2811
#define COLOR_ORDER RGB
#define NUM_LEDS    30
CRGB leds[NUM_LEDS];
#define LED 2

#define BRIGHTNESS          96
#define FRAMES_PER_SECOND  120

void setup() {
  delay(3000); // 3 second delay for recovery
  
  pinMode(LED,OUTPUT);
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);

  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}


// List of patterns to cycle through.  Each is defined as a separate function below.
typedef void (*SimplePatternList[])();
SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current
uint8_t gHue = 0; // rotating "base color" used by many of the patterns
  
void loop()
{
  
  // A blink pattern for troubleshooting
  digitalWrite(LED,LOW); 
  delay(500);
  digitalWrite(LED,HIGH);
  delay(1500);
  digitalWrite(LED,LOW); 
  delay(500);
  digitalWrite(LED,HIGH);
  
  // Call the current pattern function once, updating the 'leds' array
  gPatterns[gCurrentPatternNumber]();

  // send the 'leds' array out to the actual LED strip
  FastLED.show();  
  // insert a delay to keep the framerate modest
  FastLED.delay(1000/FRAMES_PER_SECOND); 

  // do some periodic updates
  EVERY_N_MILLISECONDS( 20 ) { gHue++; } // slowly cycle the "base color" through the rainbow
  EVERY_N_SECONDS( 10 ) { nextPattern(); } // change patterns periodically
}

#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()
{
  // add one to the current pattern number, and wrap around at the end
  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);
}

void rainbow() 
{
  // FastLED's built-in rainbow generator
  fill_rainbow( leds, NUM_LEDS, gHue, 7);
}

void rainbowWithGlitter() 
{
  // built-in FastLED rainbow, plus some random sparkly glitter
  rainbow();
  addGlitter(80);
}

void addGlitter( fract8 chanceOfGlitter) 
{
  if( random8() < chanceOfGlitter) {
    leds[ random16(NUM_LEDS) ] += CRGB::White;
  }
}

void confetti() 
{
  // random colored speckles that blink in and fade smoothly
  fadeToBlackBy( leds, NUM_LEDS, 10);
  int pos = random16(NUM_LEDS);
  leds[pos] += CHSV( gHue + random8(64), 200, 255);
}

void sinelon()
{
  // a colored dot sweeping back and forth, with fading trails
  fadeToBlackBy( leds, NUM_LEDS, 20);
  int pos = beatsin16( 13, 0, NUM_LEDS-1 );
  leds[pos] += CHSV( gHue, 255, 192);
}

void bpm()
{
  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)
  uint8_t BeatsPerMinute = 62;
  CRGBPalette16 palette = PartyColors_p;
  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
  for( int i = 0; i < NUM_LEDS; i++) { //9948
    leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
  }
}

void juggle() {
  // eight colored dots, weaving in and out of sync with each other
  fadeToBlackBy( leds, NUM_LEDS, 20);
  uint8_t dothue = 0;
  for( int i = 0; i < 8; i++) {
    leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);
    dothue += 32;
  }
}

Any ideas?

Welcome to the forum

That is a 3.3V board whereas the project that you copied used a Uno which is a 5V board

Could that be significant ?

If I were you I would start with something really simple such as blinking the first LED in the strip which is one of the FastLED examples

That's a good possibility. Adafruit has some information about level-shifting. You will need a (low power) 5V source, and the chip they recommend isn't specifically a level shifter. I've never looked-into it, but there are probably more reliable level-shifter chips.

Or maybe that 1st LED/chip is just bad. The data flows serially through all of the chips and it's buffered (re-amplified) by each chip so a bad one can kill the data to all of the following chips.

Your AliExpress link shows "bulbs", not a 300 LED strip. ...And personally, I don't trust stuff from AliExpress (or eBay, etc.) and you rarely get good documentation or links to the datasheet.

With 12V addressable LED strips, the power is 12V, the data is 5V and the LEDs are usually grouped/controlled/addressed in sets of 3.

Thank you for your reply. How can the 3V VS 5V be handled? Should I change the resistor to one with lower ohm?

Read the Adafruit link. You can "derive" 5V from the 12V supply using a voltage regulator. The LM7805 is popular but it's not critical... You only need a few milliamps at 5V to power the level-shifter chip.

No. The resistor in-line with the WS2812 is not affecting the voltage because the data-input is very-high impedance... Virtually no current flows through it so virtually no voltage is dropped across it. It's "recommended" but not "required". It may be recommended for "protection" in case something shorts-out.

A resistor is required in series with a regular LED to limit/control the current and with a higher voltage you need a higher resistance to maintain the same current (and the same brightness).

Thank you. I will get one of those and get back with a report.

Hi again,

I have now tried with the following hardware setup (with no luck):

Added after input in this thread:

I have connected the Level Converter

  • LV 1 <- 510 ohm <- ESP32, Pin 4
  • LV (3,3V) <- ESP32, Pin 3,3V
  • GND <- ESP32, Pin GND + 12V GND

  • HV 1 -> WS2811, Pin data
  • HV <- ESP32
  • GND <- ESP32, Pin GND + 12V GND

The result is as previously, the LED:s are lit static.

Any smart ideas?

Nobody?

Yes, I am here.

Show a drawing, it might help. Your code sets up for WS2811 with FastLED, then calls an array of functions. Can you verify or simplify (in another sketch) your array of functions is working?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.