SOLVED:User input turned to HEX


User inputs in serial monitor "A3" when read in hex it will be 0x41 and 0x33

I would like when read in HEX it will be 0xA3

how can i achieve this?

i know how to read the values and such and I'm reading one value at a time, so "A" then the "3"

if (ch >= ‘A’ && ch <= ‘F’) val = ch - ‘A’ + 10;

You have two characters coming in, as 1 byte each, ‘A’ and ‘3’.

check out

You can do a lookup table:
0x41 = 0x0A
0x33 = 0x03

combinedByte = 0x0A<<4 + 030x = 0xA3
0x0A<<4 shifts the bits 4 places left, puts them in the upper nibble.

Or do a test, & calculate on the fly:
if (incoming >=0x30 and incoming <=0x39){
convertedByte = incoming - 0x30;} //for 0-9
if (incoming >=0x41 and incoming <=0x46){
convertedByte = incoming - 0x37;} for A-F

and combine as above.

perfect thanks