I have a circuit that is normally battery powered. I would like to add a charger circuit (I have already chosen a 5-pin SMD - http://ww1.microchip.com/downloads/en/DeviceDoc/20001984F.pdf
). I would also like the arduino to know when I am charging, so that it can turn off all the LED's (they draw a lot of current) and possibly go to sleep.
The battery is normally about 3.7V, and USB is 5V. So could I figure out if the arduino is plugged in, by running a line from the battery positive terminal to the analog input. The Battery positive terminal is already connected to VCC through a Schottky diode.
1) If arduino is NOT plugged into 5V. The Vcc will be ~3.5V. The Analog input will be 3.7V, so the reading should be approximately 1023.
2) If arduino IS plugged into 5V. The VCC will be +5V or so. The Analog input will still be 3.7V so the reading should be about 750.
So if this is true, I should be able to take this analog reading and have the Arduino shut down the LED's if it sees a reading below 850 or so.
Does anyone see a flaw in my reasoning?
BTW here is a quick schematic of my proposed circuit: