Go Down

Topic: Convert String From Serial Data to Numerical Value (Read 3 times) previous topic - next topic

chiques


You need to be clearer about what you want to do. There is a huge difference between a string and a String. The string is not a class and does not have a toInt() method.

Frankly, you should not be using the String class at all. It has a major problem that is going to, sooner or later, bite you.


Now I'm really lost. My goal is to convert the second string to a value so I can write some algorithms.
0.000,0.000,0.000

This looks like it's converting each ASCII character

String : ASCII

0 : 48
.  : 46
0 : 48
0 : 48
0 : 48


Ref: http://arduino.cc/en/Tutorial/ASCIITable

I know this doesn't solve my conversion problem but I'm practicing difference string conversions.

PaulS

Quote
This looks like it's converting each ASCII character

Please don't post code using the invisible font.

HazardsMind

#17
Jan 16, 2013, 09:02 pm Last Edit: Jan 16, 2013, 09:11 pm by HazardsMind Reason: 1
Quote
atof (Convert string to double)
double = float.

Edit.

Created Libraries:
TFT_Extension, OneWireKeypad, SerialServo, (UPD)WiiClassicController, VWID

PaulS

Quote
This method is used for arrays, not strings.

It most certainly is for strings. It is NOT for non-NULL-terminated arrays of chars.

chiques

This will take some time to soak in.

Thanks

Go Up