SOLVED : Getting a hex chain as letters and numbers


I’ve got a problem I’ve been working on since yesterday. I’m pretty sure the solution is stupid but I’m really stuck.

First of all, here is a part of my code :

char DataParts[10];
  DataParts[0] = mfrc522.uid.uidByte[0] >> 4;
  DataParts[1] = mfrc522.uid.uidByte[0] & 0xf;
  DataParts[2] = mfrc522.uid.uidByte[1] >> 4;
  DataParts[3] = mfrc522.uid.uidByte[1] & 0xf;
  DataParts[4] = mfrc522.uid.uidByte[2] >> 4;
  DataParts[5] = mfrc522.uid.uidByte[2] & 0xf;
  DataParts[6] = mfrc522.uid.uidByte[3] >> 4;
  DataParts[7] = mfrc522.uid.uidByte[3] & 0xf;
  DataParts[8] = mfrc522.uid.uidByte[4] >> 4;
  DataParts[9] = mfrc522.uid.uidByte[4] & 0xf;

  for (byte i = 0; i < 10 ; i++){
    Keyboard.print(DataParts[i], HEX);

That code separates the hex bytes (3A becomes 2 bits, 3 and A) and then writes each bit with the keyboard.

However, I need each letter to be a lowercase and not an uppercase. I suppose I’d need to get each actual character of the card’s tag to manipulate characters with ctype.h .

How can I achieve this?

Thanks !

I am not clear what you are doing, but if you have an 'A', which is 65 decimal, then it is trivial to convert it to an 'a' which is 97 decimal.

Because you only posted a code snippet, it is hard to be sure but that looks like the hard way to go about things.

I don't know what Keyboard is, and I don't know what its print method does, but I would think that a simple lookup table could be used for this job and would only use 16 bytes.
[ 0 => '0', 1 => '1', ... , A => 'a', ... , F => 'f' ]

The function tolower(...) may also be handy.

Well thanks Bob, it perfectly works.
For some reasons, tolower didn't worked, and I thought it was already trying to go with +32 on the ascii table.

Well, this thread and its stupid question can be locked. Thanks a lot guys !