I was going to try and make a low battery voltage indicator using an LM339, and after I figured out the circuit itself I would connect it to an Arduino input, and make my program to give a visible indication of a low battery. What I was going to attempt was to have a 5v voltage regulator connected to "input 1 minus", using a voltage divider circuit with a 10-ohm resistor and a 4.7 k, to make the voltage go down by a very small amount. (voltage drop of like 0.1v on the 10 ohm resistor). Then, the 9v is hooked to a 2.2K resistor, then to ground through a 4.7K resistor, with the "input 1 plus" pin connected in between them. I use a 5k potentiometer to simulate voltage changes. The output can only sink current, so I have an LED wired to 5V, through a 470-ohm resistor then to the output.
The circuit does not seem to work as I intended. I wanted to voltage-drop the 9v through resistors to be close to 5v, so that when the battery voltage started to drop, the voltage that the chip would see would be lower than the reference voltage, causing the output to change. My LED just stays on all the time until the voltage is too low to actually light it up. That's not exactly what I'm aiming for. Am I missing something here? This circuit is currently on a bread-board by itself, I just wanted to figure out if my idea worked. So far, it doesn't.
If you use a series resistor voltage divider circuit, could you bring the battery voltage within the range of the analog inputs on the Arduino, and then just use the analog read function to check the battery level?