Call of Overloaded "println(float(&)(int)) is ambiguous

Hi everyone, thanks in advance for the help.

I am trying to create a function that I can call in a different program that converts an analog reading to a voltage.

Here is my code:

int vpin=A0;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}

void loop() {
Serial.println(vbattery);
}

float vbattery (int vpin){
float vactual;
vactual=((analogRead(vpin))/1023)*5;
return vactual;
}

What exactly is going wrong?
Thanks.

Serial.println(vbattery);

vbattery is a function but here you are treating it as a variable. It needs to be called with an integer as a parameter, in this case the pin number from which to read the analogue input. So the call will be something like

Serial.println(vbattery(A0));

And here:

vactual=((analogRead(vpin))/1023)*5;

You're taking the result of an analogRead, which is an integer between 0 and 1023, and integer dividing it by 1023. then dividing that by 5, which will return 0 for any value returned by analogRead other than 1023, which will result in 5. Probably not what you want...

That line should be:

vactual=(float)analogRead(vpin) * 5.0 / 1023.0;

Regards,
Ray L.