Convert Hexadecimal value to ASCII value manually

Status
Not open for further replies.

Fan174

Member level 2
Joined
Mar 27, 2018
Messages
51
Helped
0
Reputation
0
Reaction score
0
Trophy points
6
Activity points
413
How to convert Hexadecimal value to ASCII value Manually

For example, Value = 0x6B

If I send 0x6B to LCD. It should show 0x6B not k on the screen.
 

If you send 0x6B to the LCD, you're sending the ASCII code for “k”.

If you want to display “0x6B“, you need to send 4 ASCII characters. 0x6B==>0x30, 0x78, 0x36, 0x38.
 
The actual value is stored in binary, not in hex. If you want to display it in hex, a conversion that has to be made! Is that what you want?
 
If you send 0x6B to the LCD, you're sending the ASCII code for “k”.

If you want to display “0x6B“, you need to send 4 ASCII characters. 0x6B==>0x30, 0x78, 0x36, 0x38.
Thanks how did you know that 4 ASCII characters have to be sent ? What's the logic behind this ?
Why magical numbers 0x30, 0x78, 0x36, 0x38.? What's the logic behind this ?
 

Thanks how did you know that 4 ASCII characters have to be sent ? What's the logic behind this ?
Why magical numbers 0x30, 0x78, 0x36, 0x38.? What's the logic behind this ?

... because you expect the display to show 4 characters.

The display works with ASCII coded characters. In C you have to use a "string" as variable.
0x6B (barry accidentally misread the "B" as "8". I´ve corrected this here)
are 4 characters "0x6B":
0: has the ASCII code 0x30, or "0" as string or '0' as single character
x: has the ASCII code 0x78 , or "x" as string or 'x' as single character
6: has the ASCII code 0x36, or ... see above
B: has the ASCII character 0x42, or ... see above

Please do an internet search for "ASCII table".
While ASCII is a standard, your display may use non standard codes.
Thus even better: read the datasheet of your display. (we professionals have to do this, too)

There are libraries for every language that do this for you.

Klaus
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…