Hi
with my serial input, I am getting bytes and can print them as Serial.print(gotByte) or Serial.print(gotByte,HEX) or Serial.print(gotByte.HEX) and they print correctly.
BUT how do I convert the gotByte into a variables like gotHEX and gotDEC.
I need to "look" for certain HEX codes and then join 2 bytes (i.e."FF74") and convert the result into a value including if it is a neg or pos (2s complement)
Can Arduino do this ?
Thanks
Graham
Assume that you have entered 1234 in the InputBox of Serial Monitor with Line ending option at Newline. Arduino UNO will receive them as 0x31 0x32 0x33 0x34 and newline character as 0x0A.
Now, tell us what you want to do with the first 4-byte? Do you want to save them in a variable as 1234 (BCD coded number) or as 04D2 (hex coded natural binary number)?
That first function will print the byte as hex characters, no problem. I don't think that second one will even compile. What did you mean, exactly?
Why do you want to do that, exactly? How would the variable gotByte be different to gotHEX? Remember, all variables are stored in the Arduino's memory in binary.
If you want to check that gotByte is a certain hex value such as C9, use
one of the keys to communication is figuring out where you missed not just the point but the whole pencil and never needed to take a trip to absurdity.