I have been working on a project as a gift for my girlfriend for Christmas which involves some a bunch of standard "white" LEDs controlled by shift registers and darlington arrays, and also some RGB LED strips (WS2812B strip, 29 LEDs on strip). Everything is going fine with the white LEDs, but not so much with the RGB ones.

If I leave the RGB leds running for a while all of the LEDs on the strip turn red, except for the first one, which continues to change color. I am not sure how long "a while" is because in "short term" testing, approximately running continuously for an hour, it works fine and all of the LEDs change appropriately, but if I leave it running overnight I wake up with the issue of all red and one single RGB "working". I then have to reset to get it working again. These RGB LEDSs need to be run for long periods (24 hours) of time without "freezing". The rest of the program (with the normal LEDs) continues to work fine despite the RGB ones not.

Let me explain how I am controlling them. V_rgb is 5V (5V - 8A power supply), which it is also grounded to. Then the data line, C, is connected to an Arduino Uno, on pin 12, which is a PWM pin.

In software, I am using a Adafruit Neopixel Library to control the RGB LEDs and write their respective colors, based off the examples given in their git repo and the tutorial here.

I have pasted my code below in case that may help, but honestly I am not sure if it is software or hardware related. (unrelated code has been removed)

#include <Adafruit_NeoPixel.h>
#define rgbPin 11
#define numRGBleds 29

Adafruit_NeoPixel strip = Adafruit_NeoPixel(numRGBleds, rgbPin, NEO_GRB + NEO_KHZ800);
int colorStep = 0;
int rgbIndex = 0;

void shiftColor() {
  int i = 0;
  for (i = 0; i < numRGBleds; i++) {
    int idx = (rgbIndex + i) % numRGBleds;
    int colorVal = round(i * colorStep);
    strip.setPixelColor(idx, Wheel(colorVal & 255));

uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if (WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } if (WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  WheelPos -= 170; 
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);

void setup()
  rgbIndex = 0;
  colorStep = 255 / (numRGBleds - 1);

void loop()
  delay(1000); // Redo every second

My thoughts of what it could be are the following, let me know if any make any sense or are known issues:

  • Having issues with micros() value rollover
  • Overheating
  • Noisy power supply
  • Defective LED strip
  • black magic?

Thanks in advance for any help.


My current solution to the problem is to just reset the board using the watchdog functionality. It reboots in a few milliseconds and sometimes flashes in the process, but I would like to figure out the real problem.


So with the reset solution, I left it running overnight and it did not freeze which leads me to think it is definitely a software, not hardware, issue. I have changed some of the wiring and coding to make sure the watchdog reset is not noticeable. It resets every half hour or so. This will make sure all of the memory is cleaned, except stuff I store in the EEPROM (which I do use to make the reset less noticeable). This reset delays processing by a few milliseconds, but time is not critical, so it is not a big deal.

I still however, would like to know a more elegant way of doing this. The software reset is a bit "hacky"

  • Do the Arduino and LED strip share a common ground? You'd expect to connect more than just the signal line to the Arduino. Nov 20, 2015 at 8:15
  • @TomvanderZanden They do. Everything is connected to the same ground line through the power supply. Nov 20, 2015 at 14:03
  • Is everything connected to the same power supply? Chances are the power supply is galvanically isolated so nothing is connected to anything through it. Nov 20, 2015 at 14:10
  • @TomvanderZanden yes, all is wired through one 5V - 8A power supply. The arduino is powered through the 5V pin, which is wired in parallel to LED strip. Note that a reset does fix the problem, without disconnecting power.This is my power supply Nov 20, 2015 at 14:13
  • 2
    Try changing delay(1000) to delay(1). That way the problem might pop up a lot faster. Also, try changing rgbIndex++; to rgbIndex=(rgbIndex+1)%numRGBleds;. I thing the problem is the int rgbIndex rollover, which occurs after about 9 hours.
    – Gerben
    Nov 20, 2015 at 14:57

1 Answer 1


Try changing rgbIndex++; to rgbIndex=(rgbIndex+1)%numRGBleds;. I thing the problem is the int rgbIndex rollover, which occurs after about 9 hours.

Also try changing delay(1000) to delay(1). That way the problem might pop up a lot faster.

  • 1
    Thanks a lot for your help! I left it overnight and it is working perfectly now. Sometimes you can stare at your code for hours on end, and then someone else looks at it for 2 minutes and immediately sees the problem. Nov 21, 2015 at 16:44
  • Well, to be honest, there was nothing wrong with you code, except for the fact that computers only allocate a limited number of bit to represent a number. Anyways, glad to be of help.
    – Gerben
    Nov 21, 2015 at 18:14
  • 1
    valid point, if only arduino int was 32 bit, it would not have been an issue for 68 years, which is well beyond what I expect to actually get out of the project. And that is assuming it never loses power, which if for sure will at some point. Nov 23, 2015 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.