Using the Arduino as a voltmeter

Hi guys

Im in lack of a voltmeter. Don't worry - I just ordered a multimeter but it takes about a month to get here. While its getting here I thought I would just use the Arduino as a voltmeter. I thought it would be easy since I'm not going to read more than 5 volts. I connected a wire to A0 (Positive probe) and one to GND (Negative probe). I know that the Arduino can't read more than 5v so I thought that 1023, which is the number the Arduino actually reads, would be equal to 5v. Therefore I wrote this simple sketch:

void setup(){
  analogReference(DEFAULT);

  Serial.begin(9600);
}

void loop(){
  long probe = analogRead(0);
  float volt; 
  
  volt = 5 * probe/1023;
  Serial.println(volt);
  delay(500);
}

But it is like it can't show decimals. When I connect it to a 3.3v source from another Arduino it just displays 3.00. When connecting to 5v from another Arduino it shows 4?

What's wrong here? Do I need some sort of external hardware when I only need to measure a maximum of 5v?

Thanks!

PS: I know this won't be the post precise thing in the world.

probe is an int. 1023 is an int. Divide an int by an int, and you get an int.

On the other hand, 1023.0 is a float. Divide an int by a float, and you get a float.

Hi,

The maximum voltage on an arduino-pin is indeed 5 volt, but you can measure much higher voltages if you use 2 resistors as voltage divider.

http://playground.arduino.cc/Main/DirectMathVoltmeter

http://www.raltron.com/cust/tools/voltage_divider.asp