char buffer; // ensure it's large enough for your largest message with 1 extra byte for the trailing NULL char '\0'sprintf(buffer,"C.%d", 32); // buffer will be "C.32"sevseg.setChars(buffer);
String aCrappyString = String("C.") + String(32); // "C.32"sevseg.setChars(aCrappyString.c_str());
The example provided by the library developer uses strcpy to load the character array, like this: strcpy(displaystring, " C.59");....So, how would I replace the 59 in that example with two characters from a two-digit integer?
// We will treat our character string as an array.// For that, we need to know the array indices.// Remember, array indices start with zero.// Array indices: 012345strcpy(displaystring, " C.59");// We see that the characters for our tens digit and ones digit// will need to go into positions 3 and 4, respectively.// This is the number we want to display:byte myNumber = 60; // We split the number into its digits, thus:byte myNumberTens = (myNumber / 10); // tens digitbyte myNumberOnes = (myNumber % 10); // ones digit// Now we have the digit values.// To convert them to characters, we need to add '0' to each of them.// (The single quotes around the '0' signify that it is a character.)// As we convert each digit to a character, we insert it into its// appropriate place in the string, thus:displaystring = '0' + myNumberTens;displaystring = '0' + myNumberOnes;