Measuring battery life remaining with just an analogue in pin

oric_dan:
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.

To clarify: Knowing remaining battery power is difficult unless you know which battery you're using and have watched it die before (this is how 'smart' laptop batteries work - they store their own discharge curve inside the battery). Even so, if the load is variable (eg. varying hard disk usage) the estimate is only approximate.

Detecting when the battery is actually in the process of dying isn't difficult - the voltage typically drops off very rapidly at the end.