Display of countdown timer in LCD is not right..PLEASE HELP..

Status
Not open for further replies.

UyAb

Junior Member level 2
Joined
Mar 6, 2013
Messages
20
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
Tacloban City, Philippines
Visit site
Activity points
1,416
something's wrong with the display of my countdown timer..here's the problem..
for example: if I input 1:36,then the countdown starts from 1:36,1:35,1:34....and when the last digit becomes "0",after 1sec it should be "9" right?but instead it becomes "6"..
and same goes to the second digit..please help me finish this code..I think I need to put additional routines but I don't know how..
Some0ne out there,please show me how to do it..tnx

Code:
void display_time()
{
 Lcd_Chr(2,8,h+48);
 Lcd_Chr(2,9,':');
 Lcd_Chr(2,10,m2+48);
 Lcd_Chr(2,11,m1+48);
}
void countdown_timer()
{
 Lcd_Cmd(Lcd_Clear);
 Lcd_Out(1,1,"Time Left:");
 Lcd_Out(2,14,"H:M");
 
 for(h=code[0]-48;h>-1;h--)
 { display_time();
  for(m2=code[1]-48;m2>-1;m2--)
  { display_time();
   for(m1=code[2]-48;m1>-1;m1--)
   {display_time();
    delay_ms(1000);
   }
  }
 }
}
 
Last edited:

it should run like that..but instead, it run like this..1:34,1:33.1:32......1:30,1:23..
this is the problem..how can I eliminate this jump?
 

h, m2, m1 gets value from code[] but code[] never decrements. So, after completion of every for loop m2, m2 gets reloded with the initial value in char[]. So, it is happening like that. You have to decrement value in char[] array.
 

h, m2, m1 gets value from code[] but code[] never decrements. So, after completion of every for loop m2, m2 gets reloded with the initial value in char[]. So, it is happening like that. You have to decrement value in char[] array.
i would like to do that sir..but i'm getting confused in the "decrement value in char[] array" that you just said..i don't know how to exactly do that..
sir, if it's not to much to ask,can you please post the additional codes that u mean?if it's ok with you..
sorry for being annoying..
 

Sorry. It is not char[] but code[]. code[2] decides the value of m1 when the inner most for loop starts. If code[2] - 0x30 is 5 initially then it starts counting down till 0 and then the for loop ends. when the for loop starts again
it counts from 5. So, instead of counting from 9 to 0 and repeating. It counts from 5 to 0 and 5 to 0.
 
Last edited:

yes sir,that's my big problem now..i've tried many ways to resolve that but it didn't worked..i just don't know how to do it..
sir,what can you recommend in or for me to resolve this problem?
in codes,how can i do it?
 

You have to start uor counter from value like 2:99, 5:99... etc or you should use a minute and hour counters which starts with any value and then you decrement the value and then convert the value to string and display on LCD. So, if you start with some value like 52 for minute then it decrements till 0 and every time the value is converted to string and displayed on LCD.
 

ok sir..tnx a lot..i guess i have to change the specifications of my project..
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…