Hex to ASCII conversion algorithm

Status
Not open for further replies.

Maverickmax

Advanced Member level 1
Joined
Dec 6, 2004
Messages
404
Helped
8
Reputation
16
Reaction score
3
Trophy points
1,298
Activity points
3,689
hex to ascii algorithm

Hi

Does anyone have a code of implementing hex to ascii conversion algorithm? Or explain me how to do it

Thank you

Maverick Max
 

convert hexadecimal ascii-code algorithm

could you please specify a little more.....maybe give an example of what exactly you want to do ???
 

Right

Basically when I transmit simple data such as 'A' and I have found out that the receiver need to read hex. Therefore I would like to convert hex into ascii so that I can display characters on my LCD module

Maverick Max
 

There are different methods..
one possible solution (quick & dirty, no range checking):
Code:
const h2c[]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46};

unsigned char hex_number;
char ascii_char;

main()
{
 hex_number=0xA;  //Number to convert
 ascii_char=h2c[hex_number]; //ASCII-Code for hex_number
}
 

Here's a simple way to convert a hex nibble (h) to its ascii character equivalent (a):

Code:
a=h+((h>9)?55:49);
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…