Cool, that is a start!
Now, like I said, the relationship should be linear. If you get a value of 1023 for 5V then you'd get a value of 512 for 2.5V. It's a direct correlation. The only complication comes in with the fact that you needed a voltage divider to get the 13.8V to the arduino. Every measurement has to be scaled accordingly.
It might look something like this:
int Vin = 0;
int val = 0;
#define VDIVIDE 2.8f
void setup() {
Serial.begin(9600);
}
void loop() {
float result;
val = analogRead(Vin);
result = val / (1023.0f / 5.0f) * VDIVIDE;
Serial.println(result);
delay(1000);
}
You would need the 013 version of arduino because I don't think the println command supported floats before then. This all could be scaled and then integer math could be used. In this example VDIVIDE is the amount that the voltage was stepped down by the voltage divider. You would need to calibrate it via the procedure I outlined in my last post.