compare ASCII

Status
Not open for further replies.

alamy

New Member
Dear all..

how to compare the character...

for example...if pic receive the character..ABDC then it will reply 1234, and FGHJ then respond 5678..

thanks in advance
 
Creat a Lookup Table

For your examples it's easy. ABCDEFG corresponds to hex 0x41, 0x42, 0x43 ect. If you simply mask the high nibble (AND with 0xF0) then pack 0x30 (OR with 0x30), then 0x41 will be converted to 0x31 ( this is ASCII code for digit "1". To use letters of the alphabet past an index of 9, you will need to utilize a lookup table. In this case I would recommend masking the highest 3 bits and using the results as the index in the table.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…