I am using arduino pro mini(3.3V) model for my project.As project requirement i want to calculate the battery voltage(like how much it remaining) and store to one variable.That will be halpfull for my further steps.
So for that what should i do?
Do i need connect anything across any pin ?if yes...please explain me in detail.
which library i have to include?(if require).
i am using 9V battery.
How could i going to do it?
it would be more preferable if u explain me with example.
You can connect the battery voltage via a voltage divider to an analog port and read that. With that reading and because you know what divider you use you can calculate the voltage.
Just read up on the analogRead() and voltage dividers. And you might just want to Google around a bit
You have to have a voltage divider to get the 9 volts down to something the Arduino can read (less than the AREF voltage).
Connect a 3.3k resistor from GND to A0, connect your battery to a 10k resistor, other end of resistor to A0,
then run this sketch to see battery voltage on serial monitor. Do not connect 9 volts directly to an Arduino pin. Keep in mind, the battery voltage will stay near full voltage untii its nearly dead, so determining how "full" it is isn't straight forward.