Go Down

Topic: Fast LED Library Red and Green swapped? (Read 97 times) previous topic - next topic

Markduino

Hello Everybody,

Anyone noticed that in the fast LED library the Red and Green are swapped?
Like that:
Code: [Select]
leds[i] = CRGB::Red; // is green
and
Code: [Select]
leds[i] = CRGB::Green; // is red

Mark

Grumpy_Mike

Quote
Anyone noticed that in the fast LED library the Red and Green are swapped?
It is your LED strip, some have them swapped. Just compensate by defining the correct mode in the code.

Markduino

Does this mean there are two kind of WS2812B ?

What I should change in this small minimal example?

Code: [Select]

#include "FastLED.h"

#define NUM_LEDS 5
#define DATA_PIN 10


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

void setup()
{
  FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);  
}

void loop()
{
  leds[0] = CRGB::Red; // shows green
  leds[1] = CRGB::Green; // shows red
  leds[2] = CRGB::Blue;
  FastLED.show();
  delay(500);
  leds[0] = CRGB::Black;
  leds[1] = CRGB::Black;
  leds[2] = CRGB::Black;
  FastLED.show();
  delay(500);
}

Grumpy_Mike

Quote
Does this mean there are two kind of WS2812B
Yes. I have found the surface mount LEDs are RGB where as the individual packages, with wire ends are GRB.

Quote
What I should change in this small minimal example?
Change CRGB to CGRB and RGB>to GRB and if that doesn't work then read the documentation for the library.

Markduino

Hello Mike,

thank you. I have found it. Only the line in the setup method needs to be changed.
Here is the code:
Code: [Select]

#include "FastLED.h"

#define NUM_LEDS 5
#define DATA_PIN 10


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

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

void loop()
{
  leds[0] = CRGB::Red; // shows green
  leds[1] = CRGB::Green; // shows red
  leds[2] = CRGB::Blue;
  FastLED.show();
  delay(500);
  leds[0] = CRGB::Black;
  leds[1] = CRGB::Black;
  leds[2] = CRGB::Black;
  FastLED.show();
  delay(500);
}


I have used only WS2812B SMD LEDs.

Mark

Go Up