If your byte contains, for example, 0x41 which is the ASCII code for 'A' what do you want to show on the LCD "A" or "41"?Lets say we have HEX value,
(byte & 0xF0) // send upper nibble
((byte << 4) & 0xF0); // send lower nibble
How do I convert HEX to ASCII and display on LCD without sprintf itoa ?
I want to show " 41" on LCD displayIf your byte contains, for example, 0x41 which is the ASCII code for 'A' what do you want to show on the LCD "A" or "41"?
For each nibble:I want to show " 41" on LCD display
lsb = number & 0x0F;
msb = (number & 0xF0) >> 4;
lsbAsASCII = lsb + '0';
lsbAsASCII = (lsb - 0x0A) + 'A';
I think the OP just has one number contained in a byteYou have 2 numbers...
Fast fingers - I quickly edited it, but you managed to catch me!I think the OP just has one number contained in a byte
So where you said "msb = (number & 0xF0) >> 8;" I think the 8 should be a 4
Sorry. I've edited my post now to say it should be ignored as you corrected your post.Fast fingers - I quickly edited it, but you managed to catch me!
There is an alternative approach, rather than executing code for this create a lookup table, this will execute pretty quickly.If your byte contains, for example, 0x41 which is the ASCII code for 'A' what do you want to show on the LCD "A" or "41"?
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
![]() |
LCD ASCII Art Display | General Electronics Chat | 9 | |
R | Number (decimal) in ascii -> binary | Homework Help | 50 | |
![]() |
Understanding ASCII in Embedded development | Programming & Languages | 25 | |
![]() |
Ascii characters in C language | Programming & Languages | 28 | |
![]() |
Understanding ASCII in Embedded Firmware Development | AAC Contributors Forum | 37 |
by Jake Hertz
by Aaron Carman
by Jake Hertz