Zeit am Arduino lcd Display wird falsch ausgegeben (Komische Zeichen)?

1 Antwort

Vom Beitragsersteller als hilfreich ausgezeichnet

Das Problem ist, dass du nicht die korrekten Zeichencodes an das Display überträgst.

Das Zeichen '0' hat den Code 48, '1' ist 49, usw...

ändere also den letzten Teil deines Programms wie folgt:

logEntry[logEntryCounter].timeOfEntry[0] = hours100 + '0';
logEntry[logEntryCounter].timeOfEntry[1] = hours10 + '0';
logEntry[logEntryCounter].timeOfEntry[2] = hours1 + '0';
logEntry[logEntryCounter].timeOfEntry[3] = doublepoint;
logEntry[logEntryCounter].timeOfEntry[4] = minutes10 + '0';
logEntry[logEntryCounter].timeOfEntry[5] = minutes1 + '0';
logEntry[logEntryCounter].timeOfEntry[6] = doublepoint;
logEntry[logEntryCounter].timeOfEntry[7] = seconds10 + '0';
logEntry[logEntryCounter].timeOfEntry[8] = seconds1 + '0';

P.S.: Nur so nebenbei, der Doppelpunkt nennt sich im Englischen "colon".


Lorex04 
Beitragsersteller
 29.08.2019, 14:59

Vielen Dank für deine Hilfe. Es hat funktioniert. : )

1
Isendrak  29.08.2019, 15:13
@Lorex04

Und als Gratisbonus noch eine etwas optimiertere Version deines Programms (ggf. braucht das Teil ein paar Bytes weniger an Speicher ^^):

int seconds = millis() / 1000;
int hours = seconds / 3600;
int minutes = (seconds %= 3600) / 60;
seconds %= 60;

logEntry[logEntryCounter].timeOfEntry[0] = (hours / 100) + '0';
logEntry[logEntryCounter].timeOfEntry[1] = ((hours / 10) % 10) + '0';
logEntry[logEntryCounter].timeOfEntry[2] = (hours % 10) + '0';
logEntry[logEntryCounter].timeOfEntry[3] = ':';
logEntry[logEntryCounter].timeOfEntry[4] = (minutes / 10) + '0';
logEntry[logEntryCounter].timeOfEntry[5] = (minutes % 10) + '0';
logEntry[logEntryCounter].timeOfEntry[6] = ':';
logEntry[logEntryCounter].timeOfEntry[7] = (seconds / 10) + '0';
logEntry[logEntryCounter].timeOfEntry[8] = (seconds % 10) + '0';
1