Convert HEX to letters?

Hi guys, i have a mifare card that contains 16 bytes in one block. I succesfully write to the card and it ends up in hexadecimal on the card. Each byte contains 1 letter.

i now want to read them back with another sketch, and have sucessfully done so. But i want to convert them back to text so that i can output them in a manner i can read them in the serial monitor.

This is the way i print them to the serial monitor today:

for (byte i = 0; i < 16; i++) {
Serial.print(buffer < 0x10 ? " 0" : " ");
_ Serial.print(buffer*, HEX);_
_
}*_
And that´s no good obviously.
4D 69 63 68 61 65 6C 20 20 20 20 20 20 20 20 20
i want to convert to:
Michael and some spaces.
Can you help me?

Why not simply cast to "char" and print each element?

You have a variable ‘i’ that you don’t use. Why?

Have you considered just to print the character? No nonsense with leading zeroes and HEX.

sterretje:
You have a variable 'i' that you don't use. Why?

It's used to convert the code to italics

for (byte i = 0; i < 16; i++) {
Serial.print(buffer < 0x10 ? " 0" : " ");
_ Serial.print(char(buffer*));_
_
}*_
this is how you do it :slight_smile: Thanks for the pointer.

AWOL:
It's used to convert the code to italics

Of course, should have thought of that :frowning:

this is how you do it :slight_smile: Thanks for the pointer.

Please learn to post code correctly using code tags to avoid the italics and other nasties caused by HTML tags in code.