I am building a small circuit that will have a supply voltage of 9V from
a battery. I would like to detect when the battery is wearing out, using
a led that lights up when the voltage passes under a certain level.
You probably need to specify the battery type. Some battery types are easier
than others to monitor.
You also don't specify how much current draw for the circuit can be tolerated.
A lot of this will depend on just how long you expect to be using the battery,
whether or not you expect this detection circuit to operate all the time or just
when your own small circuit is running, how much current draw your circuit takes
and how often it's running -- questions like that.
One problem is that when your battery gets very, very low, it won't have enough
voltage to keep the detection circuit operating as designed. So while it may
work okay when the battery gets lower than some threshold voltage, there will be
yet another point below which it will cease to operate altogether.
Another issue is that running an LED continuously when the battery is low is
probably a poorer choice, as it takes away the maximum possible energy from the
battery at a time when the battery is at its weakest. A possible solution to
this is to blink the LED periodically. This reduces the average consumption at
this more difficult time. Pulsing the LED may reduce the average by one or two
orders -- which can be helpful.
And, of course, there is the issue of simple vs complex and how to trade off all
these issues. You might look at Maxim's voltage monitor ICs -- some draw only a
few microamps (thinking perhaps of the MAX6459.)
Jon