byte to hex

how can i convert a byte (0-99) to hex (0-63)? This conversion is not needed to Serial.print

I am guessing you mean ascii hex

you can use sprintf("%02X", theNumber);

this is the normal way to do it in C but the sprintf function uses a lot of program memory

you can also do

char myHexString[8];

myHexString[0] = (theNumber >> 4) + 0x30 if (myHexString[0] > 0x39) myHexString[0] +=7;

myHexString[1] = (theNumber & 0x0f) + 0x30 if (myHexString[1] > 0x39) myHexString[1] +=7;

The value is stored internally in binary. Unless you want to print the value as a string, there is no need to do any kind of "conversion", normally.

Why do you think you need to?

i need to set the contrast to a lcd
i also post other questions here

In SetContrast function if i use values 0-63 i get strange results
but if i use 0xvalue i get the right result

byte val1 = 0x63;
byte val2 = 99;

Both val1 and val2 will contain the same value.

then why the contrast on lcd is different if i use 0x35 it has a better contrast than 53 Maybe is the LCD...

Regarding my second question from the other post I want to control the intensity of the back light led using an digital pin, an resistor and transistor. Is there a way to control the amount of current flowing through that pin?

Are you passing the values the same way? Passing one as a byte-sized constant and the other as an int is not passing them the same way.