Arduino-String Formatierung Der Ausgabe

Mache ich eine Arduino-powered Uhr, und in den Prozess, ich bin versucht zu format Ganzzahlen in zwei-Ziffer-formatierte Zeichenfolgen für die Zeit Auslesen (z.B. 1 in "01").

Folgende gibt mir "Fehler: expected primary-expression before '{' token":

char * formatTimeDigits (int num) {
  char strOut[3] = "00";
  if (num < 10) {
    strOut = {'0', char(num)};
  }
  else {
    strOut = char(num);
  }
  return strOut;
}

Ich versuche, es zu benutzen, wie folgt:

void serialOutput12() {
  printWeekday(weekday); //picks the right word to print for the weekday
  Serial.print(", "); //a comma after the weekday
  Serial.print(hour12, DEC); //the hour, sent to the screen in decimal format
  Serial.print(":"); //a colon between the hour and the minute
  Serial.print(formatTimeDigits(minute)); //the minute
  Serial.print(":"); //a colon between the minute and the second
  Serial.print(formatTimeDigits(second)); //the second
}

Alle Ideen, was fehlt mir hier?

InformationsquelleAutor amb9800 | 2009-11-24
Schreibe einen Kommentar