Measuring battery life remaining with just an analogue in pin

Battery life remaining isn't overly simple to determine, but it's still a good idea to monitor
battery voltage so you know when the system is about ready to crash. If you're using an
LDO regulator that's known to dropout when Vin gets down to 6V, then when it reads
6.25V, you know it's time to make peace with the world. Save the data to EEPROM,
shutdown activities, and go to sleep.