Hi, I have a program that I am working on that works as a stopwatch. For the display it uses a five-digit, seven-segment display powered by a single shift register.
When I start the program it displays "SPLIT" for one and a half seconds then displays "59.59.0" (59 minutes 59 seconds and 0 tenths of a second) which is what I want it to do. Then if I push the "start" button (connected to pin 9) it starts counting up and after it reaches "59.59.9" it stops displaying the tenths of a second digit and starts displaying the hour digit by shifting the digits to the right (1.00.00). Pushing the "function" button (connects to pin 13) causes it to display "lap" for one and a half seconds and then goes onto the lap function.
The problem I am having is when it displays "LAP". I have the "Timer" function in the while loop because I want it to continue to increase the time but every time "nextNumber" is less than "milliseconds" digits[0](tenths second) equals 7406. When that happens it sets digit[0] to 0 and repeats setting digits[0] from 7406 to 0 until the loop exits (lines 82 -88 in code)
. After it exits the loop, the time is the same as when it entered the loop. I also tried replacing the function "DisplayLap" with the function "DisplaySplit" and digits[0] never went above 9 and it worked as I wanted it to except that it displayed "split" instead of "lap".
Why does digits[0] ever equal 7406?
StopWatch_3_0.ino (20.7 KB)