Debugging Neopixel LEDs , wrong colors displayed

Hi,

I am struggling to debug NeoPixel RGBW for an artistic project. I get weird result which stops me to go further on a more complex Script. I tried to isolate the problem, but comment ting a lot o features of my script to reduce the purpose.

I am using the Neopixel Library on an arduino 33 iOt with a proper level shifter circuit and an external Power Supply.

The main problem I have is in this comment, setting manually the color causes issues, so playing with more complex effects is not really possible.

  // uint32_t waveColor1 = 0x00FF0000; // produce Steady RED ok
  // uint32_t waveColor1 = 0xFF000000; // produce Steady WHITE ok 
  // uint32_t waveColor1 = 0x0000FF00; // produce Steady GREEN ok
  // uint32_t waveColor1 = 0x000000FF; // produce Steady BLUE ok
  uint32_t waveColor1 = 0x00FFFFFF; // produce Flashing RED ??? Should produce steady WHITE, by combining RGB

Any comment or clues to help me debug this situation, on which I already spent few hours.

Full Code:

// Led Libraries
#include <Adafruit_NeoPixel.h>

extern const uint8_t gamma8[]; // refer to Gamma table at end of sketch.

// Led Code Begin //
#define LED_PIN 2
#define NUM_PIXELS  37
#define BRIGHTNESS 50
Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRBW + NEO_KHZ800);
// Led Code End //

//[GLOBAL_VARIABLES]
unsigned long currentMillis;
unsigned long lastMillis;

unsigned long effStart;
uint16_t  effStep;

int curr = 1 ;

int reduction = 2; // divider for intensity

uint8_t arrayLen = 7;
int oldWave = 1;
int wave = 1;

int waveColor1_R = 255;
int waveColor1_G = 255;
int waveColor1_B = 255;
int waveColor1_W = 255;

int glowColor1_R = 115;
int glowColor1_G = 205;
int glowColor1_B = 255;
int glowColor1_W = 0;

int glowColor2_R = 20;
int glowColor2_G = 170;
int glowColor2_B = 155;
int glowColor2_W = 0;

int bgColor_R = 0;
int bgColor_G = 65;
int bgColor_B = 135;
int bgColor_W = 0;

// uint32_t curve1[] = {21,20,19,18,17,16,15};
// uint32_t curve2[] = {14,20,19,18,17,16,22};
// uint32_t curve3[] = {14,13,19,18,17,23,22};
// uint32_t curve4[] = {7,12,18,24,29};
// uint32_t curve5[] = {2,6,11,18,25,30,34};
// uint32_t curve6[] = {2,5,11,18,25,31,34};
// uint32_t curve7[] = {1,5,11,18,25,31,35};
// uint32_t curve8[] = {0,5,11,18,25,31,36};
// uint32_t curve9[] = {0,4,11,18,25,32,36};
// uint32_t curve10[] = {3,10,18,26,33};
// uint32_t curve11[] = {8,9,17,18,19,27,28};
// uint32_t curve12[] = {8,16,17,18,19,20,28};
// uint32_t curve13[] = {15,16,17,18,19,20,21};

uint32_t curve7[][7] = { {0,0,0,0,0,0,0},
					{21,20,19,18,17,16,15},
					{14,20,19,18,17,16,22},
					{14,13,19,18,17,23,22},
					{4,4,4,4,4,4,4},
					{2,6,11,18,25,30,34},
					{2,5,11,18,25,31,34},
					{1,5,11,18,25,31,35},
					{0,5,11,18,25,31,36},
					{0,4,11,18,25,32,36},
					{10,10,10,10,10,10,10},
					{8,9,17,18,19,27,28},
					{8,16,17,18,19,20,28},
					{15,16,17,18,19,20,21} };

uint32_t curve5[][5] = { {0,0,0,0,0},
					{1,1,1,1,1},
					{2,2,2,2,2},
					{3,3,3,3,3},
					{7,12,18,24,29},
					{5,5,5,5,5},
					{6,6,6,6,6},
					{7,7,7,7,7},
					{8,8,8,8,8},
					{9,9,9,9,9},
					{3,10,18,26,33},
					{11,11,11,11,11},
					{12,12,12,12,12},
					{13,13,13,13,13} };

uint32_t percent7[][35] = {
  {64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64},
  {64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64},
  {64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64},
  {64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83},
  {159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179},
  {255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236},
  {159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140}};

uint32_t percent5[][35] = {
  {64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64},
  {64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64,64,64,64,64,64},
  {64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83,64,64,64,64,64},
  {64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179,159,140,121,102,83},
  {159,140,121,102,83,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,64,83,102,121,140,159,179,198,217,236,255,236,217,198,179}};

uint32_t Glow11[14] = {8,9,10,11,12,13,14,22,23,24,25,26,27,28};
uint32_t Glow21[10] = {3,4,5,6,7,29,30,31,32,33};
uint32_t GlowB1[6] = {0,1,2,34,35,36};

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);

  effStart = millis();
  strip.begin();
  strip.show();
  //delay(1000);

}

void loop() {
  currentMillis = millis();

  strips_loop();

}

void strips_loop() {
  stripCurve();
  strip.show();
  delay(200);
}

void stripCurve() {

  uint32_t color1 = strip.gamma32(strip.Color(glowColor1_R,glowColor1_G,glowColor1_B,glowColor1_W));
  uint32_t color2 = strip.gamma32(strip.Color(glowColor2_R,glowColor2_G,glowColor2_B,glowColor2_W));
  uint32_t colorb = strip.gamma32(strip.Color(bgColor_R,bgColor_G,bgColor_B,bgColor_W));
  // uint32_t waveColor1 = strip.gamma32(strip.Color(waveColor1_R,waveColor1_G,waveColor1_B));
  // uint32_t waveColor1 = strip.Color(waveColor1_R,waveColor1_G,waveColor1_B);
  // uint32_t waveColor1 = 0x00FF0000; // produce Steady RED
  // uint32_t waveColor1 = 0xFF000000; // produce Steady WHITE
  // uint32_t waveColor1 = 0x0000FF00; // produce Steady GREEN
  // uint32_t waveColor1 = 0x000000FF; // produce Steady BLUE
  uint32_t waveColor1 = 0x00FFFFFF; // produce Flashing RED ???
  Serial.println(waveColor1);
  Serial.println(waveColor1);
  int t = effStep;

//if(millis() - effStart < 200 * effStep) return ;

  for (int i=0; i < arrayLen; i++) {
    // uint32_t gamma = pgm_read_byte(&gamma8[percent7[i][t]]);
    // strip.gamma32(strip.Color(0,0,0,0));
    //uint32_t colorit = strip.Color(0,0,0,pgm_read_byte(&gamma8[percent7[i][t]]));

    // strip.setPixelColor(curve7[wave][i], colorit );
    strip.setPixelColor(curve7[wave][i], waveColor1 );

  // for (int a = 0 ; a < 14 ; a++) {
  //   strip.setPixelColor(Glow11[a], colorb);
  //   }
  // for (int b = 0 ; b < 10 ; b++) {
  //   strip.setPixelColor(Glow21[b], colorb);
  //   }
  // for (int c = 0 ; c < 6 ; c++) {
  //   strip.setPixelColor(GlowB1[c], colorb);
  //   }

    //strip.setPixelColor(curve7[wave][i], 0,0,0, gamma );
    // Serial.print(i);
    // Serial.print(" ");
    // Serial.print(t);
    // Serial.print(" ");
    // Serial.print(percent7[i][t]);
    // Serial.print("  gamma: ");
    // //Serial.print(gamma);
    // Serial.print("  led: ");
    // Serial.println(curve7[wave][i]);
    // Serial.println("case default"); 
  }

  if(effStep >= 34) {
    effStart = millis();
    effStep = 0;
  }
  else effStep++;
  return;
}


const uint8_t PROGMEM gamma8[] = {
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,
    0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  1,  1,  1,  1,
    1,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2,  2,  2,  2,  2,  2,
    2,  3,  3,  3,  3,  3,  3,  3,  4,  4,  4,  4,  4,  5,  5,  5,
    5,  6,  6,  6,  6,  7,  7,  7,  7,  8,  8,  8,  9,  9,  9, 10,
   10, 10, 11, 11, 11, 12, 12, 13, 13, 13, 14, 14, 15, 15, 16, 16,
   17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 24, 24, 25,
   25, 26, 27, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36,
   37, 38, 39, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 50,
   51, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 66, 67, 68,
   69, 70, 72, 73, 74, 75, 77, 78, 79, 81, 82, 83, 85, 86, 87, 89,
   90, 92, 93, 95, 96, 98, 99,101,102,104,105,107,109,110,112,114,
  115,117,119,120,122,124,126,127,129,131,133,135,137,138,140,142,
  144,146,148,150,152,154,156,158,160,162,164,167,169,171,173,175,
  177,180,182,184,186,189,191,193,196,198,200,203,205,208,210,213,
  215,218,220,223,225,228,231,233,236,239,241,244,247,249,252,255 };
Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_GRBW + NEO_KHZ800);
// uint32_t waveColor1 = 0x00FF0000; // produce Steady RED ok
  // uint32_t waveColor1 = 0xFF000000; // produce Steady WHITE ok 
  // uint32_t waveColor1 = 0x0000FF00; // produce Steady GREEN ok
  // uint32_t waveColor1 = 0x000000FF; // produce Steady BLUE ok
  uint32_t waveColor1 = 0x00FFFFFF; // produce Flashing RED ??? Should produce steady WHITE, by combining RGB

Ignoring the flashing red this looks like the order should be

Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_WRGB + NEO_KHZ800);

Are you sure you have a RGBW string rater than a RGB string? What is the model number?

The Neopixels I use are these ones:

RGBW leds I have are these ones: I choose it as they are incorporated on a artistic project and it gives flexibility for the wiring and spacing.

NeoPixel RGBW Mini Button PCB
ref: https://www.adafruit.com/product/4776

They are all soldered in serie, simulating a strip for the software.

P.

@UKHeliBob.

Changing to :
Adafruit_NeoPixel strip(NUM_PIXELS, LED_PIN, NEO_WRGB + NEO_KHZ800);

Did not solved the issue.

P.

Please show the link to your led strip, not to PCB

Hi B707,

The link is good. These are Neopixel LEDs on a small PCB which can be soldered in series to build a a custom strip. They are sold in pack of 10.

WrongDatasheet on the Adafruit WebSite:
https://www.adafruit.com/images/product-files/1138/SK6812%20LED%20datasheet%20.pdf

Thanks.

P.

That data sheet is for an RGB LED display with 24 bit data. You should configure for an RGB display. These displays get white from the RGB combination.

1 Like

One from two is wrong - either lot title "NeoPixel RGBW..." or the datasheet that for sk6812 RGB leds

I can confirm the leds I have installed are RGBW, same as on the picture. The datasheet is the wrong one on the Neopixel site. No clue on how to find the right one...

P.

How do you know they are RGBW and not just RGB?

Hi B707,

Because if I turn white only as shown below (only the white portion of the LED lights-up.

// uint32_t waveColor1 = 0xFF000000; // produce Steady WHITE ok 

image

Normally, asking fot R: 255, G:255 B:255, W:0 would also light White, but with a combination a the RGB, but it lights RED as well.

P.

What do you consider a "proper" level shifter?

Hi Paul,

Here is a diagram of the circuit.

Let me know if it can be optimized.

P.

It's hard to understand your circuit from that diagram. Can you please post a schematic?

I'm not sure that chip is suitable. This table from it's datasheet explains why:

It says the input voltage that is recognised as HIGH must be at least 3.85V when the supply voltage is 5.5V, which is 70% of the supply voltage. So at 5.0V, it would be around 3.5V. Your Arduino only outputs 3.3V. So the signal from the Arduino may not be reliably shifted to 5V.

Adafruit recommend using a 74HCT125 in their Neopixel Uberguide. If you look at the datasheet for that chip:


you can see that the minimum voltage recognised as HIGH is much lower, meaning a 3.3V input will be reliably recognised as HIGH.

I use 74hc14 for level shifting with neopixels. The datasheet says


3.15V with a supply voltage of 4.5V (70% again), which is 3.5V at 5V supply.

So there's no guarantee that 74hc14 will always work for this. But you can also see that 3.15V is the maximum, the worst case. It could be as low as 1.7V and most chips will be somewhere between 1.7V and 3.15V. So far I have been lucky!

2 Likes

I can spot an error in the circuit. The 10K resistor isn't doing anything useful, it's just leaking a little current from Vcc to ground.

Thanks paul, for your inputs. I'll verify the exact model of Logic Level shifter. And correct it. I will also verify where I got this p/n reference.

I'll remove the 10K Resistor as well, to see. I'll keep you posted in few days when I'll be able to spend more time on the project.

Thanks.

P.

I forgot. You also need a 0.1uF ceramic bypass capacitor for the chip on the breadboard. You can put it across the breadboard power rails, close to the chip.

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