I want to detect the presence of a 8.4V voltage source from an Arduino, so I'm using a voltage divider to step it down to a voltage safe for the Arduino to read with an digital pin.
However, for when the Arduino is powered off, I also want an LED to light when the voltage is present.
How do I combine these two circuits? So the divider didn't waste power, I was using high values 2/1M ohms, but I have to lower those if I want there to be enough current to power the LED. I calculated the maximum resistence needed to light a red LED would be around 400 ohms. Will this circuit work?
This circuit essentially sits "between" a battery charger and a battery, allowing an Arduino to detect when the charger has been attached.
EP (external power) goes to an Arduino digital pin.
S1 is a normally-open magnetic reed switch closed by a magnet on the input voltage source plug. I added it because Vin is attached to a battery's positive terminal, so that's there as a safety mechanism to ensure the 8.4V contact doesn't expose live battery leads when the external plug is unplugged.
D1 is necessary to keep EP pulled low when the magnetic plug closes S1 but no power is present, indicating the charger itself is unpowered.