Hello everyone, I’m new to programmation and I am trying to implement a digital clock to be displaid on a 16x2 LCD without making use of a Real Time Clock module.
The program is intended to get the time by comparing the output of millis() (ie the time in ms since last reset) with an initial time set by the user.
The user should be able to set the time by pressing SELECT. When this is done, I want the hours to increment or decrement when PLUS or MINUS are pressed. Pressing OK should then move on to the minutes and then the seconds. When the seconds are done and OK is pressed, the program should store the output of millis() to get the “date” of the setup (relative to last reset). Adding the difference between the output of millis() at any time and the setup “date” to the initial time defined by the user would then give the actual time.
However, there are quite a lot of bugs in my code (which you can find attached to this post). As I can’t tell to what extend they are related with each other, I put a list of symptoms in the description that I have observed when testing my code.
I suspect a problem of variable type considering the recurrence of 255 (maximum for unsigned 8bit number) among the problems that I am facing.
I also think that their must be some timing issues in my SetTime() method.
Now, I’m a begginer and coding without being able to debug is just like hell to me
Could you please have a look at it and help me understanding what I’m doing wrong ?
DigitalClock.ino (6.89 KB)