Can't control WS2812B LED strip with FastLED

I used to be able to make it work with this setup, which consists of an Arduino UNO and a WS2812 LED strip, but it no longer works. This is the connection diagram:

And this is how I set it up:


The sketch I'm using:

#include <FastLED.h>

#define NUM_LEDS 1

#define DATA_PIN 3

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() { 
    
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);  // GRB ordering is typical
}

void loop() { 
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  
  FastLED.show();
  delay(500);
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;
  digitalWrite(13, LOW);
  FastLED.show();
  delay(500);
}

Is there anything wrong with my setup that made the strip unusable or something or is the board just dead?

In your diagram the LED Data In pin is connected to the 5V pin of the Uno via a capacitor and the 5V pin of the LEDs is connected to pin 7 of the Uno

Why ?

Sorry about that. The strip I'm using has the Din pin in the middle and I just assumed it's the same in thinkercard

Please post a schematic of how your project is actually wired

I updated the diagram, and the capacitor is used to level out the power to the LED strip. I tried connecting without it and 7 first LED just turned on even when there is no data pin connected


This is the wiring diagram I used.

The capacitor must be between +5V and GND (red and black) on this way the strip hasn't power.

1 Like

That is a rude thing to do because it makes comments about the original diagram nonsense

Why is the capacitor in series with the 5v line ? No current will flow through it. Shouldn't the capacitor be connected across GND and 5V lines instead ?

I'm sorry, I will edit it back the original way


So is it like this?

Better, but the capacitor is the wrong way round

2 Likes

Help! After wiring up the schematic and powering the Arduino, some of the LEDs turned on unexpectedly, and I still can't control the LED after uploading the sketch.

In the schematic you use D7 as DATA out. In your program you use

Why you use a strip with x Leds and you use

Use a number as much you use leds. Make all the leds "Black" at startup.

I've changed the code accordingly, but it still does not work.
I wonder why some of the first LEDs just start lighting up and I can't do anything about it

#include <FastLED.h>

#define NUM_LEDS 600

#define DATA_PIN 7

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() { 
    
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);  // GRB ordering is typical
}

void loop() { 
  // Turn the LED on, then pause
  leds[0] = CRGB::Red;
  
  FastLED.show();
  delay(500);
  // Now turn the LED off, then pause
  leds[0] = CRGB::Black;

  FastLED.show();
  delay(500);
}

Try this from the Fastled examples

// This function runs over and over, and is where you do the magic to light
// your leds.
void loop() {
   // Move a single white led 
   for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
      // Turn our current led on to white, then show the leds
      leds[whiteLed] = CRGB::White;

      // Show the leds (only one of which is set to white, from above)
      FastLED.show();

      // Wait a little bit
      delay(100);

      // Turn our current led back to black for the next loop around
      leds[whiteLed] = CRGB::Black;
   }
}

edit:
In setup you can place

  fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0));
  FastLED.show();

to make all leds black.

I have worked up with the code:

#include <FastLED.h>

#define NUM_LEDS 600
#define DATA_PIN 7

CRGB leds[NUM_LEDS];

void setup() { 
    FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);  // GRB ordering is typical
    fill_solid(leds, NUM_LEDS, CRGB(0, 0, 0));
    FastLED.show();
}

void loop() {
   // Move a single white led 
   for(int whiteLed = 0; whiteLed < NUM_LEDS; whiteLed = whiteLed + 1) {
      // Turn our current led on to white, then show the leds
      leds[whiteLed] = CRGB::White;

      // Show the leds (only one of which is set to white, from above)
      FastLED.show();

      // Wait a little bit
      delay(100);

      // Turn our current led back to black for the next loop around
      leds[whiteLed] = CRGB::Black;
   }
}

This is my actual wiring. The data pin is 7, and I used the above schematic with a flipped capacitor. Is anything wrong with my setup


I've tried i it again and again, still no luck

Why that resistor between data and GND?

Try another datapin maybe you have molded the pin.

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