Hi david.. I will run the LCD_ID_readreg.ino later, I also found out that the problem is some ports are not properly connected because of the cover of the arduino uno.. I'm at school.. but anyway I have another problem.. I'm trying to display the rating of a 9V battery with the voltage divider using 3-30kohms and 1-10kohms but I get a rating of 0. This is my code..

Think about my scaling method. Then look at your statement. Take a pencil and paper and do the calculation yourself. Note that an integer divide always produces an integer result. i.e. it thows away any remainder.

I'm now also using 1-30.2kohms and 3-kohms for my voltage divider, found out that the resistances are not exactly 10kohms and 30kohms.. I'm now getting this value(attached).. but my input voltage is 9.45V.. What must be the problem?

/* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

Nothing is ever perfect. Your DMM will have a tolerance for reading resistors. And a better tolerance for reading voltage.

You can read the battery voltage with the DMM. Read the voltage at the ADC pin. Read the VCC for your Arduino.

Then put those values into your calculations. It is common practice to take multiple ADC readings and average them. All the same your "single" values range from 9.85 to 10.17V. If your actual voltage is 10.01V your readings are -1.5% to +1.5% accurate. I would be happy with that.

You have probably noticed that if your "5.0V" is nearer 4.6V, all the calculations become nearer 9.0V

/* ReadAnalogVoltage Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor. Graphical representation is available using serial plotter (Tools > Serial Plotter menu) Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

David, I'm done with measuring the voltage, I'm satisfied with what I'm getting now. but my problem is measuring the current, do I need to use a current sensor? If yes, where do I need to put the pins? pin A0-A5 is already used. Thanks!