Assign RGB to LED strip, assign blue without assigning value to red?

I am using the "NewKitt" example I found in this link, and I need my LEDs to be blue. For both the posted example and my modified code, the LEDs will not show blue unless the "red" variable is assigned at least hex 0x0F. Then they show the proper color. Is this something that can be fixed? Not a big deal, just want to find out if I'm doing something silly. I am using WS2812 strips with FastLED on an Arduino Zero. Extra voltage is being supplied to the strip. The example above uses the following function to assign rgb colors.

void setPixel(int Pixel, byte red, byte green, byte blue) {
   leds[Pixel].r = red;
   leds[Pixel].g = green;
   leds[Pixel].b = blue;
}

Thank you!

Hi. Please post your entire sketch, not just a snippet.

Maybe that implementation of FastLED has a few bugs (like using it with ESP8266).

Here's my code:

#include "FastLED.h"

#define LED_PIN_FRONT    6  //define front controller pin
#define NUM_LEDS         144 //Total LEDs on each strip for quadrant
#define BAR_LENGTH       10  //number of LEDs for "bars"

//change values for LED colors
#define RED_VAL          0x0F
#define GREEN_VAL        0x0F
#define BLUE_VAL         0xFF

//delay values
#define SPEED_DELAY      20 //defines speed of LED sweep
#define SWEEP_DELAY      50 //defines how long LEDs wait before sweeping again

CRGB ledsFront[NUM_LEDS];

void setup()
{
  FastLED.addLeds<WS2812,LED_PIN_FRONT,GRB>(ledsFront,NUM_LEDS).setCorrection( TypicalLEDStrip );
}

void loop() {
  Pulse(RED_VAL, GREEN_VAL, BLUE_VAL, BAR_LENGTH, SPEED_DELAY, SWEEP_DELAY);
}

void Pulse(byte redVal, byte greenVal, byte blueVal, int barLen, int speedDelay, int sweepDelay){
  CenterToOutside(redVal, greenVal, blueVal, barLen, speedDelay, sweepDelay);
  OutsideToCenter(redVal, greenVal, blueVal, barLen, speedDelay, sweepDelay);
}

void CenterToOutside(byte redVal, byte greenVal, byte blueVal, int barLen, int speedDelay, int sweepDelay) {
  int i;
  for(i=((NUM_LEDS-barLen)/2); i>=0; i-=2) {
    setAll(0,0,0);
   
    setPixelFront(i, redVal, greenVal, blueVal);
    for(int j = 1; j <= barLen; j++) {
      setPixelFront(i+j, redVal, greenVal, blueVal);
    }
    setPixelFront(i+barLen+1, redVal, greenVal, blueVal);
   
    setPixelFront(NUM_LEDS-i, redVal, greenVal, blueVal);
    for(int j = 1; j <= barLen; j++) {
      setPixelFront(NUM_LEDS-i-j, redVal, greenVal, blueVal);
    }
    setPixelFront(NUM_LEDS-i-barLen-1, redVal, greenVal, blueVal);
   
    FastLED.show();
    delay(speedDelay);
  }
  delay(sweepDelay);
}

void OutsideToCenter(byte redVal, byte greenVal, byte blueVal, int barLen, int speedDelay, int sweepDelay) {
  int i;
  for(i=0; i<=((NUM_LEDS-barLen)/2) ; i+=2) {
    setAll(0,0,0);
   
    setPixelFront(i, redVal, greenVal, blueVal);
    for(int j = 1; j <= barLen; j++) {
      setPixelFront(i+j, redVal, greenVal, blueVal);
    }
    setPixelFront(i+barLen+1, redVal, greenVal, blueVal);
   
    setPixelFront(NUM_LEDS-i, redVal, greenVal, blueVal);
    for(int j = 1; j <= barLen; j++) {
      setPixelFront(NUM_LEDS-i-j, redVal, greenVal, blueVal);
    }
    setPixelFront(NUM_LEDS-i-barLen-1, redVal, greenVal, blueVal);
   
    FastLED.show();
    delay(speedDelay);
  }
  delay(sweepDelay);
}

void setPixelFront(int Pixel, byte red, byte green, byte blue) {
   ledsFront[Pixel].r = red;
   ledsFront[Pixel].g = green;
   ledsFront[Pixel].b = blue;
}

void setAll(byte red, byte green, byte blue) {
  for(int i = 0; i < NUM_LEDS; i++ ) {
    setPixelFront(i, red, green, blue);
  }
  FastLED.show();
}

To show correct blue color the red and green values should be near to zero. I think the value 0x0f don't have a specific meaning, it just a low enough that not to affect to blue one.

In asking to the question in heading - in addressable LED strip you can't to assign value to blue without assigning values to red and green.

Thank you so much! I didn't know that was a thing with addressable LEDs.

To clarify, this is true, but you can set all three and if red and green didn't change, you won't notice any change. So effectively, you can change only one.

Could this be RGB565 and not RGB888?

When transmitting to diodes, you cannot use RGB565 - the protocol only supports 24bit color.
However, in your program, you can use any format, but in this case you will need to convert it to 888 before transferring it.

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