Convert Decimal values to hexadecimal array

Hello, i'm working in a project but i have a problem. I use a android app to control a SEW Movidrive. For this it's necessary send one array like:

data[] = {(SD1), (ADR),(TYPE), (0x00), (0x06), (highByte(auxp)), (lowByte(auxp)), (highByte(d)), (lowByte(d)), (BCC)}

auxp and d it's decimal values and i need hexadecimal values on array...

Help please...

decimal, hex, octal, all those are different ways for HUMANS to read and write numbers. To a computer it is all binary. It doesn't matter how you write it, it will be the same number in the end.

For example, these are all EXACTLY equivalent. Any one of them could be substituted for the others.

int a = 24;

int a = 0x18;

int a = 030;

int a = 0b11000;

Yes Delta_G, i know it.
But sew movidrive wait for an array on hexadecimal form.
I could represent d and auxp using for exemple:


But i need something like

SoftwareSerial.write(data,10); //array write of size 10

Are you wanting to send it as ascii characters? If not, then it doesn’t make any difference how you write it. If you are wanting to send ascii characters, then you need to put them in as char arrays and not integers.


int data[] = {24, 0x18, 030, 0b11000};

for (int i = 0, i<4; i++){

Will send the exact same exact thing 4 times. It’s all binary to the computer. Writing it in hexadecimal is only for the humans to read.

Which communication interface are you using?

I'm using RS-485...