I have a Nano every that will be powered by 12V. I vill have one external 0-5V source going to an Analog input.
When I power off the nano it might be voltage still to the analog input. This might fry the board.
I'm planning to use a relay to send the 0-5V signal through. What about a delay in the relay, if that happens for a few ms will it fry?
But my main question or possibly my suggestion.... let say I use the "Vin" and connect it to 12v NOT USB. then when turning it on/off I just switch the "GND" for the power and all the external batteries, then the voltage can't damage anything as there are no closed circuits? Or am I just tired and stupid right now
You should make every imaginable effort to avoid connecting powered devices to unpowered devices, as both can be destroyed by the connection.
If you think that is not possible to avoid, in this case of an analog input, a 10K resistor between the external source and the analog input might prevent damage to the Arduino.
easiest way - just put a big resistor in series with the analog input.
eg 1M 5V = 5ua that will not fry the input - nor will it significantly change the reading.
( unless your 0-5V signal is changing VERY fast, as the input capacitance is only a few pF)
You would also need to add a cap at the input. 1 Meg at the input could pick up all sorts of noise.
I will admit my solution is very conservative. But since the components are cheap and not too many of them it seemed the best for someone new to Arduinos and the OP did a good job in knowing this was something to worry about.
But still does any one know if my question below will work or not? Seems super simple if it works.
let say I use the "Vin" and connect it to 12v NOT USB. then when turning it on/off I just switch the "GND" for the power and all the external batteries, then the voltage can't damage anything as there are no closed circuits?