Hi guys. I'm working on the project that requires me to run five strips of WS2812S LEDs with 214 pixels total. Everything works great on the bench but when I power it up with my actual strips all of them have a very strange flickering issue. It almost seems as if they are all turning on for a fraction of a second and then goes back to the color I tell them to. The code is below. You will see that I am purposely turning some pixels black but that's not what I am seeing. I've even commented that portion out and it still does it. My guess its cabling but I'd like to get some opinions. Each strand I soldered on 22 awg pig tails and ran 16 awg speaker wire in between. The Arduino is approximately 10' away from the first strand. If it is cabling what type of cable is recommended? Would it help moving the Arduino closer to the first strip?
#include <FastLED.h>
#include <FastLED.h>
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define LED_PIN 3
#define dimmerPin 7
#define NUM_LEDS 214
unsigned long runStartMillis;
unsigned long runCurrentMillis;
unsigned long modeStartMillis;
unsigned long modeCurrentMillis;
int runDly;
int modeDly = 10 * 1000;
int mode = 1;
int count = 0;
int modes = 4;
int brightDimmer;
int brightness;
bool upDone = false;
CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200);
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
FastLED.setBrightness(brightness);
FastLED.clear();
runStartMillis = millis();
modeStartMillis = millis();
}
void loop() {
brightDimmer = analogRead(dimmerPin);
brightDimmer = map(brightDimmer, 0, 1024, 30, 254);
brightness = brightDimmer;
runCurrentMillis = millis();
modeCurrentMillis = millis();
if (modeCurrentMillis - modeStartMillis > modeDly) {
mode = random(1, modes + 1);
modeStartMillis = modeCurrentMillis;
if (mode != 4) {
count = 0;
}
}
if (mode > modes) {
mode = 1;
}
//mode = 4;
// *** ///////////////////////////////////////////////////
if (mode == 1) {
runDly = 1;
if (runCurrentMillis - runStartMillis > runDly) {
Yellow();
runStartMillis = runCurrentMillis;
}
}
//////////////////////////////////////////////////////////
// *** ///////////////////////////////////////////////////
if (mode == 2) {
runDly = 1;
if (runCurrentMillis - runStartMillis > runDly) {
YellowGreen();
runStartMillis = runCurrentMillis;
}
}
//////////////////////////////////////////////////////////
// *** ///////////////////////////////////////////////////
if (mode == 3) {
runDly = 1;
if (runCurrentMillis - runStartMillis > runDly) {
Green();
runStartMillis = runCurrentMillis;
}
}
//////////////////////////////////////////////////////////
// *** ///////////////////////////////////////////////////
if (mode == 4) {
runDly = 30;
if (runCurrentMillis - runStartMillis > runDly) {
if (upDone == false) {
count++;
}
if (upDone == true) {
count--;
}
if (count == NUM_LEDS) {
count = NUM_LEDS - 1;
upDone = true;
}
if (upDone == true && count == 0) {
upDone = false;
}
Trail(count);
runStartMillis = runCurrentMillis;
Serial.println(count);
}
}
//////////////////////////////////////////////////////////
}
void Yellow() {
FastLED.setBrightness(brightness);
fill_solid(leds, NUM_LEDS, CRGB(255, 255, 0));
FastLED.show();
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
FastLED.show();
}
void Green() {
FastLED.setBrightness(brightness);
fill_solid(leds, NUM_LEDS, CRGB(0, 255, 0));
FastLED.show();
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
FastLED.show();
}
void YellowGreen() {
FastLED.setBrightness(brightness);
fill_solid(leds, NUM_LEDS, CRGB(128, 255, 0));
FastLED.show();
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
leds[random(0, NUM_LEDS + 1)].setRGB(0, 0, 0);
FastLED.show();
}
void Trail(int count) {
FastLED.setBrightness(brightness);
fill_solid(leds, NUM_LEDS, CRGB(255, 255, 0));
FastLED.show();
leds[count].setRGB(0, 0, 0);
FastLED.show();
}