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();
}