I want to convert micros() output which is unsigned long into hex value to store this hex value in the array.
How do i do that?
It's a binary value - you can convert it to any number base you like.
(What has this got to do with "website and forum"?)
I want to convert micros() output which is unsigned long into the hex to store this hex value in the array for later use.Serial.println (x, HEX) is of no use as i want to use this value later.
union
{
unsigned long y;
byte myData[4];
}data;
data.y = micros();
Serial.println(data.myData[0], HEX);
arpitthumar:
I want to convert micros() output which is unsigned long into the hex to store this hex value in the array for later use.
The usual way to store the value of micros() is as an unsigned long.
What do you want to do with the value that would benefit from storing it in text form as HEX ?
...R
The ltoa() function will convert the 4 byte integer into a much larger HEX character string.
But, as above, it is hard to imagine why anyone would want to store that string for later use.
TOPIC MERGED.
Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum.
Continued cross posting could result in a time out from the forum.
Bob.