Go Down

Topic: LCD counts in foreign langauge, how to change ?  (Read 454 times) previous topic - next topic

lesept

still looking for a way to reset every 24 hours.
Make a test : just after the millis() line, put
Code: [Select]
if (Clocktime > 24 * 3600 * 1000UL) Clocktime = 0;
A force d'essayer on finit par réussir... Donc, plus ça rate, plus on a de chances que ça marche (proverbe Sharduinok).

oqibidipo

Code: [Select]
if (Clocktime > 24 * 3600 * 1000UL) Clocktime = 0;
That UL is too late, 24*3600 is still int*int. Make it
Code: [Select]
if (Clocktime > 24UL * 3600 * 1000) Clocktime = 0;

odometer

yeah.. that turned out to be somewhat true, taught me a lot, but probaly a waste of your time.

So what happened was...;
Rewiring didn't solve the problem, so i started looking at the code. since I used the hourglass project, my "start" was the completed code of that project. Since that project uses a tilt switch to emulate the turning of an hourglass that code was still (partly) included. I don't know exactly how that changed the characters ( can dig up the code if anyone really wants to know, since i saved the fixed version in a new file) but taking it out fixed all the problems.
The reason we were not able to help you solve your problem was that we did not have the right information to be able to help you.

From what you wrote in your first post, it sounded as though you were running an exact copy of the sketch from https://www.arduino.cc/en/Tutorial/HelloWorld when this problem occurred. If you had told us that you had made additions to that sketch, and shown us the code you were actually running, then we would likely have been able to find the real problem and help you fix it.

odometer

Make a test : just after the millis() line, put
Code: [Select]
if (Clocktime > 24 * 3600 * 1000UL) Clocktime = 0;
That UL is too late, 24*3600 is still int*int. Make it
Code: [Select]
if (Clocktime > 24UL * 3600 * 1000) Clocktime = 0;
You are both wrong.

Take a look again at the code from reply #14, especially this line:
Code: [Select]
  Clocktime = millis();
The way you two have it, the clock will correctly count up to either 05:47:43 or 23:59:59, at which point it will jump to 00:00:00 and stay frozen at 00:00:00 for about seven weeks (until millis() overflows), at which point it will start counting up again.

odometer

#19
Sep 16, 2018, 08:15 am Last Edit: Sep 16, 2018, 08:15 am by odometer
Here is what I'd suggest:
Code: [Select]
unsigned long Clocktime;
byte Tenhours, Hours, Tenminutes, Minutes, TenSeconds, Seconds;

I would suggest being more consistent with your capitalization. To you, the difference between Variablename and VariableName might not matter, but to the compiler it very much does matter, and if you use one system for all of your variable names, that will make things easier for yourself and anyone else who wishes to read or modify your code.

Go Up