UniqueID

Please can someone help, I am trying to display the UniqueID of an Arduino to the LCD, but can’t for the life of me remember how to make the serial number available as a constant I can call outside of the Void Setup.

Many thanks for any help,

//
// ArduinoUniqueID.ino
//
// Example shows the UniqueID on the Serial Monitor.
//

#include <ArduinoUniqueID.h>

void setup()
{
	Serial.begin(115200);
	UniqueIDdump(Serial);
	Serial.print("UniqueID: ");
	for (size_t i = 0; i < UniqueIDsize; i++)
	{
		if (UniqueID[i] < 0x10)
			Serial.print("0");
		Serial.print(UniqueID[i], HEX);
		Serial.print(" ");
	}
	Serial.println();
}

void loop()
{
  Serial.println(UniqueID);
}

(deleted)

Thank you for the reply, however I think i am still doing something wrong as the call doesn’t seem to work?

//
// ArduinoUniqueID.ino
//
// Example shows the UniqueID on the Serial Monitor.
//

#include <ArduinoUniqueID.h>

void setup()
{
	Serial.begin(115200);
	UniqueIDdump(Serial);
}

void loop()
{
  Serial.println(UniqueID);
}

void showTheNumber()
{Serial.print("UniqueID: ");
  for (size_t i = 0; i < UniqueIDsize; i++)
  {
    if (UniqueID[i] < 0x10)
      Serial.print("0");
    Serial.print(UniqueID[i], HEX);
    Serial.print(" ");
  }
  Serial.println();
}

The GitHub example has the for loop in setup() whereas you have it in loop(). Make loop() empty by moving the for loop to setup().

Did you want to store the binary bytes as a string of hex characters that you can print later?

#include <ArduinoUniqueID.h>


char UniqueIDString[(UniqueIDsize * 2) + 1];


void setup()
{
  Serial.begin(115200);


  UniqueIDdump(Serial);  // Prints "UniqueID: 55 35 35 33 31 30 0D 1A 25"


  byte index = 0;
  for (size_t i = 0; i < UniqueIDsize; i++)
  {
    UniqueIDString[index++] = "0123456789ABCDEF"[UniqueID[i] >> 4];
    UniqueIDString[index++] = "0123456789ABCDEF"[UniqueID[i]  & 0x0F];
  }
  UniqueIDString[index++] = 0; // Null Terminator
}


void loop()
{
  Serial.print("UniqueID: ");
  Serial.println(UniqueIDString); // Prints: 5535353331300D1A25
  delay(5000);
}