# Converting 0 to 24V analog signal to 0 to 5V for ADC input?

I'm using ATMEGA16U4 microcontroller and want to Convert the 0 to 24V analog signal to 0 to 5V for ADC input.

How to Convert 0 to 10V analog signal to 0 to 2.5V for ADC input?

and I'm using R1 =4.7K ohm and R2=1.2 Kohm which makes my output impedance R1||R2= 0.95Kohm which satisfies my ADC output impedance of approximately 10 kΩ or less( as mentioned in the datasheet of ATMEGA16U4 datasheet).

Am I right or do I need to change them?

-
See similar question: ADC: Need to convert 10V-32V(from battery 0-32V) range to 0-5V –  Phil Frost Jan 9 '13 at 22:27

Sounds right to me. I calculate that a 24V input will result in a 4.88V output. But since you are asking, I'm assuming this isn't what's actually happening. Is the voltage you are trying to measure provided by a low-impedance source? Otherwise, you will have to include that impedance as part of R1, or buffer the signal with an op-amp or such.

-
The voltage I am trying to measure is from a battery source of 24V. –  VarshaReDDy Jan 9 '13 at 22:07
If it's a small battery and you don't want to run it down, you might be better off using higher-valued resistors ($470k\Omega$, $210k\Omega$ for example) and meeting the impedance requirement with a buffer. With the values you have selected, you are consuming about 0.1 watts in your resistors. –  Phil Frost Jan 9 '13 at 22:11
Also, since it's a safe bet you are measuring battery voltage because you want to know how much capacity is remaining, you may want to instead research power management ICs. There are plenty available that will do a much better job of managing a battery, and they aren't very expensive. –  Phil Frost Jan 9 '13 at 22:16
If a battery management IC doesn't meet your requirements, you might also consider a zener diode to drop a portion of the battery voltage -- most batteries don't really go from 0-24V, you'd probably be fine with 18-30V mapped to 0-5V. –  HikeOnPast Jan 9 '13 at 22:25