hello everyone. I would like to know how we can calculate the resistor value attached to the Arduino and the battery (2.2Kohms).
I know that we use the voltage divider but I just can't figure it out and I know that the maximum current that I can draw from an Arduino pin is 40 mA. If someone plz could help me get this right.
I want to test cell batteries using this schematic from the 65 projects book.

??
A voltage divider requires two or more resistors. R4 in your circuit doesn't do anything.
A better battery tester would be to apply a brief load on the battery, then measure the voltage. The unloaded voltage only tells you if the battery is truly dead beyond all use. Coin-cell batteries will measure good unloaded but drop in voltage very fast under load. I.E., dead.
In my opinion, this circuit is worthless for measuring coin cells.
Pick one
The calculation is
Vout= (R2/(R1 + R2)) * Vin
Simple voltage dividers have all the issues outlined by Steve but sometimes it’s all you need.