Go Down

Topic: Individually addressing LEDs strip via ws2811 on arduino uno with FastLED lib (Read 5205 times) previous topic - next topic

artmole

Hi there, i want to light one of three LEDs in my led-strip, while keeping the others turned off. Right now i can only get the same color for each of the LEDs.



The ledstrip is a worldsemi RGB led strip with GND, DIN and 12v.
I am using the library fastLed for arduino and i am running the code from their own example, as seen below.

As said, i CAN light all of the LEDs in one color, however I CANNOT light them individually.

Thanks!


Code: [Select]

// Use if you want to force the software SPI subsystem to be used for some reason (generally, you don't)
// #define FASTLED_FORCE_SOFTWARE_SPI
// Use if you want to force non-accelerated pin access (hint: you really don't, it breaks lots of things)
// #define FASTLED_FORCE_SOFTWARE_SPI
// #define FASTLED_FORCE_SOFTWARE_PINS
#include "FastLED.h"

///////////////////////////////////////////////////////////////////////////////////////////
//
// Move a white dot along the strip of leds.  This program simply shows how to configure the leds,
// and then how to turn a single pixel white and then off, moving down the line of pixels.
//

// How many leds are in the strip?
#define NUM_LEDS 3

// Data pin that led data will be written out over
#define DATA_PIN 6

// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

// This is an array of leds.  One item for each led in your strip.
CRGB leds[NUM_LEDS];

void setup() {
// sanity check delay - allows reprogramming if accidently blowing power w/leds
    delay(2000);
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);

}

// your leds.
void loop() {
      leds[0] = CRGB::Red;
      leds[1] = CRGB::Black;
      leds[2] = CRGB::Black;
      FastLED.show();

}

PaulRB

On this line
Code: [Select]
      // FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);


The two slashes indicate that the line is "commented out" and ignored/not executed. That line is essential for the FastLED library to work.

artmole

Hm, i just uncommented the line (which i have done before, just forgot this time)
Im still having the same problem.

PaulRB

Dang, thought I had it there!

So using the above sketch with the addLeds line included, all three leds light up red?


INTP

Have you wired everything up correctly? How we know you know what 'correctly' means unless you actually show us what you've done?
Try putting a:

FastLED.clear();

as the last line in your setup().


And don't bother with
      leds[1] = CRGB::Black;
      leds[2] = CRGB::Black;

just work 1 led at a time until you know it's working as you think it does

ntan

I am having the same issue. I have modified the FastLED code for the correct color and pin and the suggestion above for the FastLED.Clear(); command, otherwise it is the same example code that came in the library, RGBCalibrate. My library is version 3.1.3. Here is what it is doing:


Code: [Select]

#include "FastLED.h"


////////////////////////////////////////////////////////////////////////////////////////////////////
//
// RGB Calibration code
//
// Use this sketch to determine what the RGB ordering for your chipset should be.  Steps for setting up to use:

// * Uncomment the line in setup that corresponds to the LED chipset that you are using.  (Note that they
//   all explicitly specify the RGB order as RGB)
// * Define DATA_PIN to the pin that data is connected to.
// * (Optional) if using software SPI for chipsets that are SPI based, define CLOCK_PIN to the clock pin
// * Compile/upload/run the sketch

// You should see six leds on.  If the RGB ordering is correct, you should see 1 red led, 2 green
// leds, and 3 blue leds.  If you see different colors, the count of each color tells you what the
// position for that color in the rgb orering should be.  So, for example, if you see 1 Blue, and 2
// Red, and 3 Green leds then the rgb ordering should be BRG (Blue, Red, Green). 

// You can then test this ordering by setting the RGB ordering in the addLeds line below to the new ordering
// and it should come out correctly, 1 red, 2 green, and 3 blue.
//
//////////////////////////////////////////////////

#define NUM_LEDS 6

// Data pin that led data will be written out over
#define DATA_PIN 10
// Clock pin only needed for SPI based chipsets when not using hardware SPI
//#define CLOCK_PIN 8

CRGB leds[NUM_LEDS];

void setup() {
// sanity check delay - allows reprogramming if accidently blowing power w/leds
    delay(2000);

      // Uncomment one of the following lines for your leds arrangement.
      // FastLED.addLeds<TM1803, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1804, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<TM1809, DATA_PIN, RGB>(leds, NUM_LEDS);
       FastLED.addLeds<WS2811, DATA_PIN, BRG>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
      // FastLED.setBrightness(CRGB(255,255,255));
      // FastLED.addLeds<GW6205, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<GW6205_400, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903, DATA_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<UCS1903B, DATA_PIN, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, 9, 10, RGB>(leds, NUM_LEDS);

      // FastLED.addLeds<WS2801, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
      // FastLED.addLeds<LPD8806, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);

      FastLED.clear();
}

void loop() {
   leds[0] = CRGB(255,0,0);
   leds[1] = CRGB(0,255,0);
   leds[2] = CRGB(0,255,0);
   leds[3] = CRGB(0,0,255);
   leds[4] = CRGB(0,0,255);
   leds[5] = CRGB(0,0,255);
   FastLED.show();
   delay(1000);
}

ntan

I just realized that there is one WS2811 IC for every 3 leds which is why I am seeing this effect. Perhaps the OP had the same issue. Watch out when you are buying these strips!

Go Up