adrian.eremencu
Newbie level 3
- Joined
- May 25, 2013
- Messages
- 4
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,356
Hi,
I have a problem with the following loop in C. It's a countdown for 4 digits(mm:ss).
For example: if i have the values 15:30 (mm:ss) it decreases the sec2 val until is less than 0, then the value of sec2 is changed to 9 and sec1 is decreased by 1, and this process continues until all digits are = 0. The countdown works but when it reaches 00:00 it doesn't stop.
I have a problem with the following loop in C. It's a countdown for 4 digits(mm:ss).
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 void countdown(void) // the countdown { while ( min2 >= 0) { while (min1 >= 0) { while (sec2 >= 0) { while ( sec1 >=0) { sec1--; delay_1s(); } sec1 = 9; sec2--; } sec2 = 5; sec2--; } min1 = 9; min2--; } }
For example: if i have the values 15:30 (mm:ss) it decreases the sec2 val until is less than 0, then the value of sec2 is changed to 9 and sec1 is decreased by 1, and this process continues until all digits are = 0. The countdown works but when it reaches 00:00 it doesn't stop.