Any best practises to prevent confetti when powering down Arduino/Leds when cutting power?

Any best practises to prevent confetti when powering down Arduino/Leds when cutting power?

I’m making a light installation and people should be able to pull the power directly (just with the main switch). I was thinking in having a capacitor that just gives enough power for a few milliseconds. In the loop() I’ll poll an analog pin to check the supply voltage (with a voltage divider). When the voltage goes down, I’ll turn the leds directly to black.

I think you’re going to need a pretty big capacitor to do that!
By the time time the arduino recognizes the power is off I think it will be too late. The power will no longer be lighting the LED strip to receive the signal from the arduino to make them all black.

How many LEDs?

128 leds.

I thought the confetti is caused by the Arduino losing power (brown-out) instead of the leds. So my first thought was adding the capacitor for the Arduino. I suppose an Arduino uses about 40mA (http://forum.arduino.cc/index.php?topic=5536.0).

So that would mean that I have 8ms with 1000uF:
http://mustcalculate.com/electronics/capacitorchargeanddischarge.php?vfrom=5&vto=4.6&vs=0&c=1000u&r=100

I might be misunderstanding your setup. When you say the power is switched off, is that for everything LED strip and arduino, or just the arduino?

Also, what LED chip set are you using, as I guess that would effect how fast you can update those 128 pixels.

No it’s for everything. So indeed the leds lose power as well.
I use the APA102, so they update within 1ms.

I’m just thinking in this scenario, so I was wondering if anyone tried something similar. Otherwise I think I just have to run some tests. It could be that the leds brown-out before and that that causes the confetti effect.

Hmmm, maaaaybe you can update them in time… I guess a test is needed! Keep us updated, I’m interested in what you find out.

This will be a fascinating test. You could use a supercapacitor. They’ve come down in price recently and are pretty tiny compared to huge electrolytics. See:
http://www.mouser.com/Power/Supercapacitors/_/N-6uivw?P=1z0x2cc&Ns=Pricing|0
There you see a 0.1F (100000 uF!) 5V supercap for $3.08.

Though you would probably want to isolate the cap from the 5V going to the strip, else the strip will steal all the cap juice. So put a Schottky diode in between the power supply and the supercap+Arduino.

A cap array in parallel worked for me: 1000µF, 10µF, 1µF, 100nF, 10nF. The large caps keep the power up for a few msec and the small caps are fast enough to filter out nasty spikes. Look at your power supply with the scope when switched off. If the spike is too high, a 5.6V Zener is a good advice.
BZA956A: http://www.nxp.com/documents/data_sheet/BZA900A_SERIES.pdf

@Kasper_Kamperman
Have you tried holding RESET (to prevent the Arduino from pushing out updates) while disconnecting the power? Does the confetti still happen then? If so, the LEDs are browning out slowly, most likely due to a high output capacitance in your power supply.

@Luminous_Elements I’ll try thanks, it might be something like that. I already wanted to implement a MOSFET to disconnect power from the leds, so I can cut power directly.