void setup() {
String myString="123.5";
float myNumber=0;
myNumber=myString.toFloat();
}
void loop() {
}
Thanks for the support,,,,Do you mean a variable of type String or of type char array? If your number is stored in a String object (or variable), it has a function/method associated with it called toFloat(). Hence, conversion is one line of code.
Here is a link to the Arduino reference pages, describing the String class.C:void setup() { String myString="123.5"; float myNumber=0; myNumber=myString.toFloat(); } void loop() { }
I personally think this is easier than scanf/printf...
by Aaron Carman
by Jake Hertz
by Duane Benson
by Jake Hertz