ref = analogRead(14) reads Analog pin 0 - that should give you a value between 0 and 1023
if you connect GND to A0 ==> you should read 0
if you connect 5V to A0 ==> you should get 1023
The right formula is
Voltage = 5.0 * ref / 1023; // there is always discussion if this should be 1023 or 1024, in practice the diff is less than the noise
Only if you set the - analogReference() - Arduino Reference - to 1.1 volt the formula should be
Voltage = 1.1 * ref / 1023;
in terms of code // use spaces and empty lines to improve readability
int ref;
float Vin;
void setup()
{
Serial.begin(9600); // you can use 115200 12x faster!
delay(1000);
}
void loop()
{
ref = analogRead(14); // or A0
Vin = 5.0 * ref / 1023;
Serial.print(Vin);
Serial.print(",");
Serial.println(ref);
delay(100);
}