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:

void loop() {

float vbattery (int vpin){
float vactual;
return vactual;

What exactly is going wrong?


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


And here:


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;

Ray L.