0

I am receiving bytes, converting them into hex and now I need to convert the hex to ASCII. Can it be done on an Arduino? Or do I need something else? I am new to programming with Arduino.

  • Is this connected to your earlier question? It is not clear, what you mean. In your previous code you are explicitly sending an ASCII version of hex (human readable hex). – chrisl Nov 12 '18 at 11:41
  • i am receiving bytes and then converting them into hex or displaying them as hex ,and now i want to display them as ascii , is that possible ? sorry for this maybe dumb questions but i want to learn. – Ivanh23 Nov 12 '18 at 11:47
  • Can you show your (relevant) code, the location where you want to convert it, and describe how the output should look like? – Michel Keijzers Nov 12 '18 at 12:06
2

If you have a byte variable b, you can

  • write(b) it as it is. if it is ASCII code of a readable character, the Serial Monitor will display it as that character, for example for 65 it will printt 'A'
  • print it as decimal number with print(b). for 65 it will print "65"
  • print it as hexadecimal number with print(b, HEX). for 65 it will print "41"
  • print it as a number in other base with print(b, base), for example print(b, 2) will print 1000001 if b is 65 in decimal
| improve this answer | |
  • @Ivanh23, did this help? – Juraj Nov 14 '18 at 12:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.