Hi all,
I have recently faced a challenge with merging two arrays of different types. I know this is a repetitive question but I searched for a long time in other forums with the same problem but didn't get the answer.
So, I have an array for the microcontroller's Unique ID containing 9 bytes of numbers in it which needs to be printed in HEX format. And on the other side, I have an array of ASCII characters of type BYTE that I need to merge together. I tried SPRINTF, SPRINTNF and STRCAT codes but it returns messed up numbers only!!!
I downloaded the uniqueID library from Github :
https://github.com/ricaun/ArduinoUniqueID
The array that I want to merge it with is:
byte buff[]={"Unique ID="};
I just don't want to print the buff array next to the Unique ID, I want them to be merged under one array. I know the code will print UniqueID size which is only 9 bytes, but even when I increase it to 30 bytes in the for loop, it prints zeros after the Unique ID serial number.
#include "ArduinoUniqueID.h"
void setup()
{
delay(1000);
byte buffer[25]={"Unique ID= "};
Serial.begin(115200);
snprintf(buffer, "%s%s", UniqueID);
for (size_t i = 0; i < UniqueIDsize; i++)
{
if (UniqueID[i] < 0x10)
delay(100);
Serial.print(buffer[i],HEX);
}
}
void loop()
{
}