WS2812B Turn Solid White After 1 Second

Hey All -

Working on a project and stumped on an issue. Hardware includes

  • Arduino Nano
  • x6 WS2812B Strips (8 LEDs each)
  • 1000uF Capacitor
  • 5V / 2.4A Power Supply

When I have a single strip attached to the Nano and power up, it works great - emulating something fire-like in a loop.

The Issue
If I attach 3 or more strips and power up, the fire animation lasts about 1 second then all LEDs on all strips turn white indefinitely.

I've tried everything even going so far as desoldering everything and starting from scratch without luck. I even tried moving the strips to different pins and can't nail anything down.

A fritzing drawing & code are below - any suggestions? Thanks!

(Power rail on breadboard supplied with 5V / 2.4A)

Code (Didn't write myself)

// Falcon Heavy (or other rocket) animation of flames/smoke

//   This code drives an array of NeoPixels (WS2812B) installed in the 

//   center of a 3D Printed rocket flame and smoke plume.  

//

// Copyright 2018 Danal Estes all right reserved.  No part of this code may be reproduced, in whole or in part, by any means, without prior written permission from Danal Estes

// Released under Creative Commons - Non Commercial - Attribution license. 

// This code is made available "As Is". No warranty of merchantability or fitness for a particular puprose is expressed or implied. 

#include <Adafruit_NeoPixel.h>  //Adafruit Supplied.

// Adafruit Pro Trinket Pin Definitions:

// UART RX               0

// UART TX               1

// USB                   2    //Internally assigned

#define STRIP0           3

#define STRIP1           4

#define STRIP2           5

#define STRIP3           6

// USB                   7    //Internally assigned

//Not Used               8

//                      5V

//                     BUS

//                     GND

//                     BAT

// This is the corner of the board on a Pro Trinket.  The pins below are on the other side. 

#define STRIP4           9

#define STRIP5          10

//SPI MOSI              11

//SPI MISO              12

//SPI SCK               13

#define LED             13    // Onboard LED (not NeoPixel) pin

//Not Used              A0

//Not Used              A1

//Not Used              A2

//Not Used              A3   

//I2C SDA               A4

//I2C SCL               A5

//#define I2C_PULLUPS_ENABLE         PORTC |= 1<<4; PORTC |= 1<<5;   // PIN A4&A5 (SDA&SCL)

//#define I2C_PULLUPS_DISABLE        PORTC &= ~(1<<4); PORTC &= ~(1<<5);

// Pro Trnk "Inside" pins.

//Not Used              A6

//Not Used              A7

// NEOPIXEL DEFINITIONS --------------------------------------------------------

// Parameter 1 = number of pixels in strip

// Parameter 2 = pin number (most are valid)

// Parameter 3 = pixel type flags, add together as needed:

//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)

//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)

//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)

//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

#define PIXELSPERSTRIP 8

Adafruit_NeoPixel Strip0 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP0, NEO_GRB + NEO_KHZ800);

Adafruit_NeoPixel Strip1 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP1, NEO_GRB + NEO_KHZ800);

Adafruit_NeoPixel Strip2 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP2, NEO_GRB + NEO_KHZ800);

Adafruit_NeoPixel Strip3 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP3, NEO_GRB + NEO_KHZ800);

Adafruit_NeoPixel Strip4 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP4, NEO_GRB + NEO_KHZ800);

Adafruit_NeoPixel Strip5 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP5, NEO_GRB + NEO_KHZ800);

// ANIMATION STUFF -------------------------------------------------------------

#define       AnimatePeriod 10L

unsigned long loopMillis;

unsigned long prevMillis = 0L;

uint32_t      pixelQueue[PIXELSPERSTRIP];

uint8_t       pFadeQueue[PIXELSPERSTRIP];

uint8_t       otherColor = 0;

// Setup          -------------------------------------------------------------

void setup() {

  pinMode(LED, OUTPUT);

  Strip0.begin();

  Strip1.begin();

  Strip2.begin();

  Strip3.begin();

  Strip4.begin();

  Strip5.begin();

}

// Loop           -------------------------------------------------------------

void loop() {

   loopMillis = millis();

   if (!((loopMillis - prevMillis) >= AnimatePeriod)) {return;}

   prevMillis = loopMillis;

    pixelQueue[PIXELSPERSTRIP-1] = Strip0.Color(255, 128, 000); 

    pFadeQueue[PIXELSPERSTRIP-1] = 1;

  if (random(1024) >  768) {

    pixelQueue[PIXELSPERSTRIP-1] = Strip0.Color(64, 032, 000);

    pFadeQueue[PIXELSPERSTRIP-1] = 1;

  } else if ((0==otherColor) && (random(1024) > 1000)) {

    pixelQueue[PIXELSPERSTRIP-1] = Strip0.Color(255, 255, 255);

    pFadeQueue[PIXELSPERSTRIP-1] = 0;

    flashAllPixels(5,Strip0.Color(255, 255, 255));

    otherColor = PIXELSPERSTRIP * 2;

  } else if ((0==otherColor) && (random(1024) > 1000)) {

    pixelQueue[PIXELSPERSTRIP-1] = Strip0.Color(255, 000, 000);

    pFadeQueue[PIXELSPERSTRIP-1] = 0;

    otherColor = PIXELSPERSTRIP * 2;

  }

 

  setAllPixels();   

  showAllStrips();

  advanceQueue();

  (0 == otherColor) ? otherColor : otherColor--;

}

// Service Subfuncitons  -------------------------------------------------------

void flashAllPixels(int ms, uint32_t color) {

  for(int i=0; i < PIXELSPERSTRIP; i++) {setPixelColorAllStrips(i, color);}

  showAllStrips();

  delay(ms);  

  prevMillis+=500;

}

void setAllPixels() {

  for(int i=0; i < PIXELSPERSTRIP; i++) {

    if (pFadeQueue[i]) {

      uint8_t r = ((i+1) * uint8_t(pixelQueue[i] >> 16)) / PIXELSPERSTRIP;

      uint8_t g = ((i+1) * uint8_t(pixelQueue[i] >>  8)) / PIXELSPERSTRIP;

      uint8_t b = ((i+1) * uint8_t(pixelQueue[i]      )) / PIXELSPERSTRIP;

      setPixelColorAllStrips(i, Strip0.Color(r, g, b));

    } else {

      setPixelColorAllStrips(i, pixelQueue[i]);

    }

  }

}

void setPixelColorAllStrips(int i, uint32_t color) {

  Strip0.setPixelColor(i, color);

  Strip1.setPixelColor(i, color);

  Strip2.setPixelColor(i, color);

  Strip3.setPixelColor(i, color);

  Strip4.setPixelColor(i, color);

  Strip5.setPixelColor(i, color);

}

void advanceQueue() {

    for(int i=0; i < PIXELSPERSTRIP - 1; i++) {

      pixelQueue[i] = pixelQueue[i+1];

      pFadeQueue[i] = pFadeQueue[i+1];

    }

}

void showAllStrips() {

  Strip0.show();

  Strip1.show();

  Strip2.show();

  Strip3.show();

  Strip4.show();

  Strip5.show();

}

5V from breadboard appears to be connected to the Vin pin of the Nano. Should be the 5V pin.

Another strange thing about your diagram is that the Nano is not plugged into the breadboard. Why is that? Is it because you have seen many pictures of arduino and they are not plugged into the breadboard? That's probably because those pictures show Uno, Mega etc. You can't plug those into a breadboard. But Nano is designed to be plugged into the breadboard.

This is the sketch in a readable format.
What shall we do with the sketch ?
How about the conflict with the "prior written permission" and the "Creative Commons - Non Commercial" ?

// Falcon Heavy (or other rocket) animation of flames/smoke
//   This code drives an array of NeoPixels (WS2812B) installed in the
//   center of a 3D Printed rocket flame and smoke plume.
//
// Copyright 2018 Danal Estes all right reserved.  No part of this code may be reproduced, in whole or in part, by any means, without prior written permission from Danal Estes
// Released under Creative Commons - Non Commercial - Attribution license.
// This code is made available "As Is". No warranty of merchantability or fitness for a particular puprose is expressed or implied.

#include <Adafruit_NeoPixel.h>  //Adafruit Supplied.

// Adafruit Pro Trinket Pin Definitions:
// UART RX               0
// UART TX               1
// USB                   2    //Internally assigned

#define STRIP0           3
#define STRIP1           4
#define STRIP2           5
#define STRIP3           6

// USB                   7    //Internally assigned
//Not Used               8
//                      5V
//                     BUS
//                     GND
//                     BAT

// This is the corner of the board on a Pro Trinket.  The pins below are on the other side.

#define STRIP4           9
#define STRIP5          10

//SPI MOSI              11
//SPI MISO              12
//SPI SCK               13

#define LED             13    // Onboard LED (not NeoPixel) pin

//Not Used              A0
//Not Used              A1
//Not Used              A2
//Not Used              A3
//I2C SDA               A4
//I2C SCL               A5

//#define I2C_PULLUPS_ENABLE         PORTC |= 1<<4; PORTC |= 1<<5;   // PIN A4&A5 (SDA&SCL)
//#define I2C_PULLUPS_DISABLE        PORTC &= ~(1<<4); PORTC &= ~(1<<5);

// Pro Trnk "Inside" pins.
//Not Used              A6
//Not Used              A7

// NEOPIXEL DEFINITIONS --------------------------------------------------------
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)

#define PIXELSPERSTRIP 8

Adafruit_NeoPixel Strip0 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP0, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Strip1 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Strip2 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Strip3 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP3, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Strip4 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP4, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel Strip5 = Adafruit_NeoPixel(PIXELSPERSTRIP, STRIP5, NEO_GRB + NEO_KHZ800);

// ANIMATION STUFF -------------------------------------------------------------
#define       AnimatePeriod 10L
unsigned long loopMillis;
unsigned long prevMillis = 0L;
uint32_t      pixelQueue[PIXELSPERSTRIP];
uint8_t       pFadeQueue[PIXELSPERSTRIP];
uint8_t       otherColor = 0;


// Setup          -------------------------------------------------------------
void setup()
{
  pinMode(LED, OUTPUT);
  Strip0.begin();
  Strip1.begin();
  Strip2.begin();
  Strip3.begin();
  Strip4.begin();
  Strip5.begin();
}

// Loop           -------------------------------------------------------------
void loop()
{
  loopMillis = millis();
  if (!((loopMillis - prevMillis) >= AnimatePeriod))
  {
    return;
  }
  prevMillis = loopMillis;
  pixelQueue[PIXELSPERSTRIP - 1] = Strip0.Color(255, 128, 000);
  pFadeQueue[PIXELSPERSTRIP - 1] = 1;
  if (random(1024) > 768)
  {
    pixelQueue[PIXELSPERSTRIP - 1] = Strip0.Color(64, 032, 000);
    pFadeQueue[PIXELSPERSTRIP - 1] = 1;
  }
  else if ((0 == otherColor) && (random(1024) > 1000))
  {
    pixelQueue[PIXELSPERSTRIP - 1] = Strip0.Color(255, 255, 255);
    pFadeQueue[PIXELSPERSTRIP - 1] = 0;
    flashAllPixels(5, Strip0.Color(255, 255, 255));
    otherColor = PIXELSPERSTRIP * 2;
  }
  else if ((0 == otherColor) && (random(1024) > 1000))
  {
    pixelQueue[PIXELSPERSTRIP - 1] = Strip0.Color(255, 000, 000);
    pFadeQueue[PIXELSPERSTRIP - 1] = 0;
    otherColor = PIXELSPERSTRIP * 2;
  }

  setAllPixels();
  showAllStrips();
  advanceQueue();
  (0 == otherColor) ? otherColor : otherColor--;
}

// Service Subfuncitons  -------------------------------------------------------

void flashAllPixels(int ms, uint32_t color)
{
  for (int i = 0; i < PIXELSPERSTRIP; i++)
  {
    setPixelColorAllStrips(i, color);
  }
  showAllStrips();
  delay(ms);
  prevMillis += 500;
}

void setAllPixels()
{
  for (int i = 0; i < PIXELSPERSTRIP; i++)
  {
    if (pFadeQueue[i])
    {
      uint8_t r = ((i + 1) * uint8_t(pixelQueue[i] >> 16)) / PIXELSPERSTRIP;
      uint8_t g = ((i + 1) * uint8_t(pixelQueue[i] >>  8)) / PIXELSPERSTRIP;
      uint8_t b = ((i + 1) * uint8_t(pixelQueue[i]      )) / PIXELSPERSTRIP;
      setPixelColorAllStrips(i, Strip0.Color(r, g, b));
    }
    else
    {
      setPixelColorAllStrips(i, pixelQueue[i]);
    }
  }
}

void setPixelColorAllStrips(int i, uint32_t color)
{
  Strip0.setPixelColor(i, color);
  Strip1.setPixelColor(i, color);
  Strip2.setPixelColor(i, color);
  Strip3.setPixelColor(i, color);
  Strip4.setPixelColor(i, color);
  Strip5.setPixelColor(i, color);
}

void advanceQueue()
{
  for (int i = 0; i < PIXELSPERSTRIP - 1; i++)
  {
    pixelQueue[i] = pixelQueue[i + 1];
    pFadeQueue[i] = pFadeQueue[i + 1];
  }
}

void showAllStrips()
{
  Strip0.show();
  Strip1.show();
  Strip2.show();
  Strip3.show();
  Strip4.show();
  Strip5.show();
}

Should all ledstrips do the same pattern ?
The sketch works in a simulation:

Thanks for the fast replies, all -

About the breadboard, yea, I know it can be plugged in, but not even using one - just added it to diagram so I could use power rail to demonstrate more easily.

I moved the power from VIN to 5V and now its working. Craziness as I'm certain I had tried that before and didn't know it could make a difference like that.

Thanks, All!

OK, here's a suggestion.

Never use "Vin". The Arduino requires 5 V to operate, so power it with 5 V using - the "5V" pin. As a discipline, forget that "Vin" exists; the on-board regulator is basically useless for any real project. :grin:

Vin pin is connected to the on-board 5V regulator on the Nano. The regulator needs at least 6.5V input to give a 5V output. If you give it less than 6.5V, it will output the best voltage it can, but won't be able to hit 5V. So if you give it 5V input, you will probably only get around 3.5V output, so the main chip on the Nano will be running on only 3.5V. In theory, that's not enough to guarantee a 16MHz Nano will run at all, but often they do, as with yours. The side effect of this is that the output pins of the nano will only output a 3.5V signal. That's really close to the limit of what the ws2812 LEDs need to read the signal. If you are lucky, the ws2812 will still be able to read that signal, but change things even slightly and it might stop working, which is what happened to you when you connected the other strips.

With the 5V power connected to the 5V pin of the Nano, the regulator is bypassed and the main chip runs at 5V and outputs 5V signals which the ws2812 LEDs have no problems reading.

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