The easiest way to understand how to read the values from analog pins and map these values back to voltage values is to work with a very simple example. We will connect a power source to one of the analog input pins, specifically a pack with two AA or AAA 1.25 V rechargeable batteries in series. It is also possible to use AA or AAA 1.5 V standard batteries in series. Note that the maximum voltage with the two rechargeable batteries in series will be 2.5 V (1.25 V * 2), while the maximum voltage with the two standard batteries in series will be 3 V (1.5 V * 2).
We will use the analog pin labeled A0 to connect to the positive side (+) of the battery pack. Don't forget that the positive side (+) of the batter pack is connected to the battery's nipple. After we finish the necessary wirings, we will write Python code to measure the batteries pack voltage. This way, we will read the result of converting an analog value to its digital representation...