ASCII to Hex
askpoly
Posts: 11
I need to accept a two byte input from Hyperterminal via Uart object. This input will be ASCII. I then need to convert this input to hex for output on a shift register. From what I can tell, there is not a single method for doing this. I am considering bringing in the ASCII character, then using some sort of array as a look up table. Is there a simpler method? Inputs will range from 0x00 to 0xFF (the user will not need to input the "0x" of course.
Thanks
George
Thanks
George
Comments
If you treat each incoming byte as a separate character and apply the pseudo code below, then after the two bytes, the result in 'H' should be what you are after....
Where:
N is the ASCII value
H is the Hex value that you want
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.