// SafeString_Example1e.ino // install the SafeString library from the Arduino Library manager or // download and install the SafeString zip file from // www.forward.com.au/pfod/ArduinoProgramming/SafeString/index.html #include "SafeString.h" createSafeString(msgStr, 10, "A0"); // increased to capacity of 10 and initial value of A0 void setup() { // Open serial communications and wait a few seconds Serial.begin(9600); for (int i = 10; i > 0; i--) { Serial.print(' '); Serial.print(i); delay(500); } Serial.println(); SafeString::setOutput(Serial); // enable error messages and debug() output to be sent to Serial if (SafeString::errorDetected()) { while (1) { Serial.println(F("Error is SafeString globals!!")); delay(3000); } } } void loop() { msgStr.clear(); // remove the initial value msgStr.print(analogRead(A0), HEX); msgStr -= " = 0x"; msgStr.prefix(F("A0")); Serial.println(msgStr); while (1) { // stop here delay(1); // add delay(1) to prevent ESP32 reboots } }