Take VDD divided by the MAX A/D reading, and multiply times 256.
5 / 1023 * 256 = 1.251
Scale that up to however many decimal places you want.
For 3 decimal places, multiply by 1000.
= 1251
So your current number is correct for 10-bit A/D with 3 decimals. (0-4999)
If you only want 2 decimals as indicated in your post, use 125 instead. (0-499)
Or you can calculate to 3 decimals, then add 5 and divide by 10 and you'll get a rounded number. (0-500)
4999 + 5 = 5004, /10 = 500
<br>




Bookmarks