Arduino lack of accuracy in AD conversion
The problem is how your calculation is being expressed.  The calculation for voltage will be done using integer math and then the result is converted to a double, resulting in the values you report.  Corrected code:


void setup() {
Serial.begin (9600); }

void loop() {
int code = analogRead (A2);
double voltage = (double)code * 5.0 / 1024.0;
Serial.print("Voltage is ");
Serial.println(voltage);
delay (500); }