Hi i make an oscilator and multimeter from arduino uno and everything work great,
i am using 9V battary, my problem is when the battary is weak the vaules will be wrong
so how i can make the arduino show up the level of the battary!!
Are you using the 9V from the battery as a refence for your multimeter? Battery's voltage is not constant (not even linear) thru their life.
You can measure the battery's voltage using your board's analog inputs. But make sure to scale the voltage between 0 and 5V max!!! (A little less should be fine, to let a safety margin)
yup i am using the analog pin, and 9V battary
oh so you want me to repeat the same way to the main battary !
good idea, with some resestors that's will work fine, but what about the battary life ! i think in this way you are killing the battary !
With high enough resistors values, the current drawn will be very low, not reducing the battery's life since the board itself will draw way more current.
Just don't forget that the analog pin has a high but not infinite impedance to ground: you'll have to take it into account in order to have an accurate result.
I think the analog inputs expect an input impedance of 100K or less. You can use two 100K resistors in series to divide your 9V nominal voltage down to 4.5V. A 200k across a 9V battery will only use 45 microamps.
Once the 9V battery drops to below about 7V the output of the 5V regulator will start to drop. You can measure the internal 1.1V reference to determine what level the "5V" is currently at and then use that value to measure the 9V. Once the output of the 5V regulator drops below 3.78V you should not use it at 16 MHz.