Hi, I am new to Arudino programming and have a problem converting a variable string to a float.
I have been able to convert a fixed HEX string to a float using the following:
union
{
unsigned long a ;
float b ;
} u ;
const char *hexString = "BFCE4000";
u.a=strtoul(hexString,NULL,16);
lcd.print(u.b);
But the string that i’m receiving (eventually via serial) is more like the following
<A,BFCE4000>
So I need to strip off all but the hex value, and to check my code I have created a sample array, of possible values:
String results[ARRAYSIZE] = { "<A,BFCE4000>", "<B,00000000>", "<A,BFCE4000>", "<B,C04E4000>", "<A,C533C300>", "<B,C5334200>", "<A,404E4000>", "<B,C09AB000>", "<A,41347800>", "<B,C11AB000>" };
But I can’t get the string to convert to HEX or to a Float, I have spend probably a good 3 hours trying different codes I have found around these forums and Stackoverflow.