Go Down

Topic: How to prevent WS2812 LEDs lighting up when Arduino Uno R3 powers on (Read 216 times) previous topic - next topic

psteiner

Hi,

First time poster, Arduino beginner.

In a circuit connecting a string of twenty (20) WS2812 RGB LEDs to a "Kuman" Arduino Uno R3 clone, all of the LEDs light up for 2 or 3 seconds after power is first supplied to the Arduino.

Is there a way to keep all LEDs off until the sketch main loop starts running?

It's not a showstopper if I can't suppress the LEDs at boot, but I'm concerned the initial ~250mA power draw will eventually burn out the Arduino.



At power up, I measured about 248 mA drawn on the LED circuit with all 20 LEDs lit up.



Power drops to about 43 mA once the sketch runs with only two LEDs lit, a blue LED "chasing" a red LED around the string.



"Data In" on the first LED is connected to pin 6 on the Arduino (with a 470R resistor in series  as recommended by Adafruit).

Power and Ground are connected to the +5V and Ground pins of the Arduino.

The LEDs illuminate at start up whether power is supplied by the USB port or by the 5.5mm power connector. I have tried both a 9V battery and a 9V wall wart power adapter.

I also tried the suggestion in this post regarding a similar problem with a servo motor receiving power when the Arduino initializes, to put a 10K pull down resistor on the output pin, but all LEDs still light up at power on:




Finally, I get the same result with this circuit and sketch on an Elegoo Arduino Uno R3 clone, so I don't think the problem is particular to the Kuman clone.

Any suggestions are more than welcome!

Code: [Select]

#include <FastLED.h>
#define NUM_LEDS 20
#define DATA_PIN 6
CRGB leds[NUM_LEDS];

void setup()
{
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
  FastLED.setBrightness(64);
}

void loop()
{
  // Did not work
  //FastLED.clear();

  // Cycle through the string of LEDs
  for (int i = 0; i < NUM_LEDS; i++)
  {
    // Set LED i to blue
    leds[i] = CRGB::Blue;
 
    // Set the LED following the blue LED to red
    leds[(i + 1) % NUM_LEDS] = CRGB::Red;
    
    // display the blue and red LEDs
    FastLED.show();

    // Clear both LEDS
    leds[i % NUM_LEDS] = CRGB::Black;
    leds[(i + 1) % NUM_LEDS] = CRGB::Black;

    // wait half a second
    delay(500);
  }
}

larryd

If it is necessary to prevent power on flashing, leave the power on.
Or
Power the strip through a relay contact and power the relay once the program is running.

Also see this recommended setup.

No technical PMs.
The last thing you did is where you should start looking.

Grumpy_Mike

Yes this happens sometimes and it appears to be random. It might have something to do with the rise time of the power supply. I notice you are not using any capacitors across the strip's supply, so try that and see if it stops.

psteiner

@grumpy_mike thank you for the help. I have capacitors coming on the slow boat from China (literally).

Since this will eventually be a binary LED clock, my intent is to leave the circuit running continuously after  power on, so the initial flash is acceptable.

Once I try the cap I'll update this thread with the results.

psteiner

@grumpy_mike at long last I've received a few 1000uF 35V electrolytic capacitors! I tried wiring up the LED strip with the cap in parallel across the 5V supply, as in the diagram @larryd indicated, but I got the same result - all of the LEDs light up full power, until the Arduino boots up and sends a control signal on the data line.

I don't think it's a showstopper for my project, I'll just live with it!

Thanks again for all your help.

Go Up