HEX Split

You don't even need to sprintf it. You are looking at extracting out the number, 4 bits at a time, right?

void setup ()
  {
  Serial.begin (115200);
  unsigned long hexString = 0x1FE3DC;
  
  for (byte i = 0; i < 8; i++)
    {
    byte nibble = hexString & 0xF;
    Serial.println (nibble, HEX);
    hexString >>= 4;
    
    if (nibble == 0xD)
       Serial.println ("Got a D!");
    }
  }  // end of setup

void loop () { }

Output:

C
D
Got a D!
3
E
F
1
0
0

Note that this method extracts from the right.

Thank you for code! That is almost what i want
Greate is that it works. But it is not exactly what I want. Nibble just search an character in hex string, but i need to seperate every char as unique data carrier.

I will try to explain for what i want it. I using Infra red to send data using IrRemote library. I am trying to use it for Laser Tag
For example sender is gun with IR, when gun shoot it send IR hex or dec string to another players receiver.
That code what is sended, need contains data about in which team is that player, what is player number, what gun mode it use, ....
for example 35AACF HEX code is sended

so in hex we know that
hex 0x1 =1
hex 0x2 =2
...
hex 0xE=14
hex 0xF=15

(First Char) ---> 3 (it will means in which team player is (0x3)third team)
(Second Char) ---> 5 (it will means which player by number it is (0x5)fifth player)
(Third Char) ---> A (it will means what gun it use - pistol which subtract (0x5) 5% of lives, or blaster who subtract(0xA) 10%)
(Fourth Char) ---> A (it will means - something else)
.....

so on receiver i need to seperate the code for use it every char as unique
example
FirstChar = (First char of sended code 35AACF)
SecondChar = (Second char of sended code 35AACF)
ThirdChar = (Third char of sended code 35AACF)
....

if (SecondChar == 0x5)
then
add 1 score to player with number 5 and Show on display which player was kill me;

if (ThirdChar == 0xA)
then
then it is blaster and subtract 10% lives from players lives;

BIG THANKS to Nick Gammon!
Using Code which post Nick Gammon + I figure out how to use BUF and i get result by myself about what I all time asking from start of this post!!! :slight_smile:

Check this out!!!

void setup ()
  {
  Serial.begin (115200);
  unsigned long hexString = 0x1FD3DC;
  unsigned int buf[8];
  int Variable0;
  int Variable1;
  int Variable2;
  int Variable3;
  int Variable4;
  int Variable5;
  
  for (byte i = 0; i < 8; i++)
      {
       byte nibble = hexString & 0xF;
       (buf[i]) = nibble;    
       hexString >>= 4;
       }
      
    Variable0 = (buf[5]);
    Variable1 = (buf[4]);
    Variable2 = (buf[3]);
    Variable3 = (buf[2]);
    Variable4 = (buf[1]);
    Variable5 = (buf[0]);
    
    Serial.print("V0= ");
    Serial.println (Variable0,HEX);
    Serial.print("V1= ");
    Serial.println (Variable1,HEX);
    Serial.print("V2= ");
    Serial.println (Variable2,HEX);
    Serial.print("V3= ");
    Serial.println (Variable3,HEX);
    Serial.print("V4= ");
    Serial.println (Variable4,HEX);
    Serial.print("V5= ");
    Serial.println (Variable5,HEX);
    
  } 

void loop () { }