0

i wanted to convert a double to a string i tested several examples online i allawys get the same error.

the code :

void setup()
{
 Serial.begin(9600);
}
void loop()
{
 double val =3.2222;
 String stringOne = String(val, 3);
 Serial.print(stringOne);
}

the errors :

sketch_jun02c.ino: In function ‘void loop()’:
sketch_jun02c.ino:10:36: error: call of overloaded ‘String(double&, int)’ is ambiguous
sketch_jun02c.ino:10:36: note: candidates are:
In file included from /usr/share/arduino/hardware/arduino/cores/arduino/Arduino.h:192:0,
 from sketch_jun02c.ino:2:
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:70:11: note: String::String(long unsigned int, unsigned char)
 explicit String(unsigned long, unsigned char base=10);
 ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:69:11: note: String::String(long int, unsigned char)
 explicit String(long, unsigned char base=10);
 ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:68:11: note: String::String(unsigned int, unsigned char)
 explicit String(unsigned int, unsigned char base=10);
 ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:67:11: note: String::String(int, unsigned char)
 explicit String(int, unsigned char base=10);
 ^
/usr/share/arduino/hardware/arduino/cores/arduino/WString.h:66:11: note: String::String(unsigned char, unsigned char)
 explicit String(unsigned char, unsigned char base=10);
 ^
asked Jun 2, 2017 at 15:48
7
  • 1
    Which IDE version are you using? The fact it's showing /usr/share/arduino tells me you installed it with apt-get (or similar), so you're probably on something ridiculously ancient. Commented Jun 2, 2017 at 16:14
  • Yes i used apt-get, the version i am using is: ARDUINO 1.0.5 - 2013年05月15日, is there a way to update it without deleting the old version ? Commented Jun 2, 2017 at 16:36
  • Download the new version from the website, extract it, and run it. Commented Jun 2, 2017 at 17:17
  • The current Arduino SDK version is 1.8.2. So 1.0.5 is really old. Package managers do not necessarily stay up to date. Especially with packages that don't make up the core of the OS. In C++ the types of the arguments are just as important as the name of the function you are calling. No (perfect) match means no function will be called. So it does not look like there is a matching "Strings()" function. That is, a "Strings()" function where the type of the argument is a double. Commented Jun 3, 2017 at 4:30
  • Yea thank you, after upgradign the IDE to 1.8.2 the program worked fine ! Commented Jun 3, 2017 at 12:54

1 Answer 1

0

I had installed arduino using apt-get and I didnt notice that I had an old version. I upgraded my arduino and it worked fine.

answered Nov 17, 2017 at 9:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.