I'm building a fairly basic addressable LED setup with an arduino mega hooked up to a PC and a neopixel ring with 12 LEDs hooked up to an external 5V/2.5A PSU using a setup like in the following image you have likely all seen on this forum many times already:
I have some question related to the two following "best practices" mentioned for neopixels:
Avoid connecting NeoPixels to a live circuit. If you simply must, always connect ground first, then +5V, then data. Disconnect in the reverse order.
If powering the pixels with a separate supply, apply power to the pixels before applying power to the microcontroller
From some searching around I've found that the LEDs might try to parasitically draw power through the dataline if they are not powered up, potentially damaging the arduino. Is this correct? If so, is there a way to build the circuit so the arduino is protected in case my PSU gets disconnected while the arduino is still connected to the PC (and possibly still trying to control the LEDs)?
The 470 Ohm resistor will limit the current that the LEDs can draw from the Arduino pin to a safe level.
Homework question for you though:
What is the maximum possible current that the LEDs could draw from the Arduino pin with the circuit you posted?
You will need to understand Ohm's law to answer.
You can power the Uno through its 5V pin from the LED power supply, that way they will both be powered at the same time.
You know, I was so focused on unraveling those two practices that I completely forgot to think about the resistor. (mostly because the adafruit neopixel uberguide mentions it being there to catch voltage spikes).
The arduino is connected to the PC because I also want to use it as a USB input device, so even if I powered it with the PSU I'd still run into the parasitic draw if the PSU were to disconnect at any point.
If I'm calculating this correctly, 5V with 470 Ohms would limit it to 10.64mA?
A follow-up question out of curiosity: if I were interested in completely eliminating any possible draw when the PSU goes out but not the arduino, what would be a good practice to achieve this?
You mean something like reading the PSU into a pin and turning the LEDs off if no signal? Because these leds' quiescent current is ~0.6 mA per led even when "off" so my 12 LEDS would still try to take 7.2mA. Though I guess this would be stopped if I switched the data pin over to input?
I considered this as well, but can't a mosfet achieve a similar result, except without taking up a pin? (and leaving the arduino doing some unnecessary led logic).
Yes. If the pin is an input then the current into or out of it is negligible. You could also leave it as an output and make sure it is LOW, meaning 0V / ground, so no voltage across the resistor.
Does that mean that if I had enough of these rings connected to different pins, the arduino could turn on at some point even with the USB disconnected (and I assume cause havoc)?