Analog In Question


I'm working on a battery monitor for my Arduino project and I was wondering if I could run a 9v battery directly into one of the Analog Inputs to measure the remaining battery %... Or would I have to use a voltage divider first?

I'm using an Arduino Diecimila.

You have to use a voltage divider first or risk damage to the chip. Use two equal size series connected resistors wired to Vin and ground and measure the resistor junction connection. You can then scale the resultant measurement by X2 or just use it as a raw count.


As lefty said, a voltage divider is the way to go. However, if you are using it as a battery monitor don't forget that you will never get 100% if you simply use the input as your percentage. Remember that the divider is dividing a max of 9 volts, so the most you will get is 4.5, which is 9/10 of the max. To get a real total percentage, multiply the input read by 10/9, then divide by 1024. That will be it!

Alright thanks for the replies guys!
Just another quick question, Lefty said to use the VIN pin… I’m already using the VIN pin so would an analog pin still work for this?

The voltage divider goes across the battery, the junction of the two resistors to an analogue pin, and the 0V from the battery is tied to the Arduino's GND. 9V goes to Vin on the Arduino. You must not put 9V onto any of the analogue pins.

Another point to remember is that a 9V battery gives you over 9V when it is new so make sure that the maximum voltage you are going to get at the input pins is never more than 5V. You might want to add some protection:- in the form of clamping diodes and up the resistor shown here to about 100R.