Go Down

Topic: need a bit of itoa help (Read 692 times) previous topic - next topic

davidb

Hi all,
Need some advice on converting a series of ascii ints into the number they actually make up (e.g. 49 48 48 >> 100). Currently I'm reading data from a digital compass (heading, pitch, & roll) using newsoftserial. Usually I've been simply passing the data to the UART Tx and that's that. Now I actually want to use the data to do some onboard processing. The packet from the compass is three floats, separated by commas, ending in both a carriage return and line feed. Heading is always positive (0. - 360.), pitch and roll positive or negative (-90. to +90, -180. to +180., respectively).  Breaking up the packet isn't that difficult thanks to the commas and line feed. My hurdle is converting "49 49 48 46 53" into "110.5", and then using it as a float in other calculations on the arduino. itoa is what I would use on the mac side...and it seems like this is what I should use on the arduino side, but I'm not finding much info, and my attempts so far won't even compile. Any advice on references or example code...or even a different method?

Thanks in advance!

David

Coding Badly

I believe you're looking for [glow]atof[/glow].  It's in [glow]stdlib.h[/glow].

Good luck,
Brian

davidb

Perfect!
Thanks for the nudge!
Best,
David

Go Up