void DecToHex(long Value, int noOfBytes) {
char buf0[5];
char buf1[5];
char format[] = "%0.4X";
if (noOfBytes < 2) {
format[3] = '2';
}
sprintf(buf0, format, Value);
if (noOfBytes > 2) {
sprintf(buf1, format, Value >> 16);
Serial.print(buf1);
}
Serial.println(buf0);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Start");
byte x = 0xFF123456;
DecToHex(x, sizeof(x));
int y = 0xFF123456;
DecToHex(y, sizeof(y));
long z = 0xFF123456;
DecToHex(z, sizeof(z));
}
void loop() {
// put your main code here, to run repeatedly:
}