i want to send a long variable over the serial port. This code is working as pure C code:
long var = 1000000;
char arr[32];
sprintf(arr,"%.8X",var);
printf("%s",arr);
wich produces the desired output 000F4240
However on the Arduino i cannot get the equivalent code working correctly
long var = 1000000;
char arr[32];
sprintf(arr,"%.8X",var);
Serial.print("%s",arr);
This always results in 00004240, neglecting the MSB and 3rd byte.
Thanks for all your time and help!!!
seems that the arduino's implementation of sprintf only converts in hexadecimal representation only an int
number, not a long
... But I'm not sure...
Strange... this question is the inverse
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.