Ok, I'm stuck. I've read about 5 tutorials on how to use int sprintf() to create an int. I've tried several flags to copy the 4 positions of my byte variable (%i, %c, %%) but it's not transferring to my int. I need the value of int MachAdd to equal "0x01" from the sprintf(). I assumed I needed the "%c" in the second position because of the 'x' in the HEX number.
The assistance is greatly appreciated.
This is the last int sprintf() I've tried:
byte MachAddX[4];
int MachAdd = 0x01;
byte sa[1];
setup()
{
sprintf( MachAddX, "0x%02X", sa[0]); <--The value of sa[0] is "1" from a previous process.
delay(10);
int sprintf( MachAdd, "%1u%1c%1u%1u", MachAddX[0], MachAddX[1], MachAddX[2], MachAddX[3]);
Serial.write( MachAddX[0]); Serial.write(MachAddX[1]); Serial.write(MachAddX[2]); Serial.write(MachAddX[3]);
delay(50);
Serial.print(MachAdd);
delay(200);
}
The outputs I get are:
MachAddX = 0x01; <---The correct value I need
MachAdd = 0; <---This should also be "0x01"