Search code examples
serial-porthexhexdump

How to convert integer/number into hex data


I am building an Android app that interacts with devices that are connected via USB ports. I am trying to figure out the formula or looking for online too to convert the number into the correct hex data for product ID and vendor ID.

Here is my data:

9025 = 0x2341 (Arduino vendor id)
5824 = 0x16C0
1155 = 0x0483

What I am looking for is a formula or tool (online) that will convert the values on the left hand side into the right-hand side. I used this, https://codebeautify.org/string-hex-converter. But it is not giving me the expected result.


Solution

  • Here you go:

    Serial.println(9025,HEX);