simple count down timer..can someone tell me why it doesn't work?

#include <LiquidCrystal.h>
LiquidCrystal lcd(8,9,10,11,12,13);

int sec=1;
int minu=1;
int hr=1;
unsigned long time=0;
unsigned long pstimer=0;

int pbuttonA=1;
int pbuttonB=1;

//========================================================================================================================

void setup() {  
lcd.begin(16,2);
pinMode (5, OUTPUT);
pinMode (6, OUTPUT);

pinMode(A2,INPUT_PULLUP);
pinMode(A3,INPUT_PULLUP);

digitalWrite (5,HIGH);

}


//========================================================================================================================
void loop() {

int cbuttonA=digitalRead (A2);  
int cbuttonB=digitalRead (A3); 

if (cbuttonA != pbuttonA){
if(cbuttonA==LOW){
minu++;
}
}
pbuttonA=cbuttonA;

if (cbuttonB != pbuttonB){
if(cbuttonB==LOW){
hr++;
}
}
pbuttonB=cbuttonB;


  
unsigned long timer= millis();
 if(timer-pstimer > 1000){
   sec--;  
   pstimer = timer;
 }  
 
if(sec==0){
 sec=60; 
 minu--;
}

if(minu==0){
 minu=60;
 hr--;
} 



    
//================================Time and mah

char szTime[8];
sprintf( szTime, "T%02d:%02d:%02d", hr, minu, sec );
lcd.setCursor(0,0);
lcd.print( szTime );


}

unbelievable , programming is so hard... just a number missed, everything won't wrok!!!!!

char szTime[11];

Yep, computers are kinda funny about that, doing exactly what you tell them do 8)

CrossRoads:
Yep, computers are kinda funny about that, doing exactly what you tell them do 8)

thank you soooo much for your quick respond. You are being very helpful to us noobs. and I am very appreciated this help. Here is the finished code of my little project. it is a timer based door lock.

#include <LiquidCrystal.h>
#include <Servo.h> 
LiquidCrystal lcd(8,9,10,11,12,13);

int sec=3;
int minu=0;
int hr=0;

unsigned long pstimer=0;

int pbuttonA=1;
int pbuttonB=1;
int pbuttonC=1;
int pbuttonD=1;

int countdown=0;

Servo myservo;
//========================================================================================================================

void setup() {  
lcd.begin(16,2);
pinMode (5, OUTPUT);

pinMode(A2,INPUT_PULLUP);
pinMode(A3,INPUT_PULLUP);
pinMode(A4,INPUT_PULLUP);
pinMode(A5,INPUT_PULLUP);

digitalWrite (5,HIGH);

  myservo.attach(6);  
}


//========================================================================================================================
void loop() {

int cbuttonA=digitalRead (A2);  
int cbuttonB=digitalRead (A3); 
int cbuttonC=digitalRead (A4); 
int cbuttonD=digitalRead (A5); 

if (cbuttonA != pbuttonA){
if(cbuttonA==LOW){
minu++;
}
}
pbuttonA=cbuttonA;

if (cbuttonB != pbuttonB){
if(cbuttonB==LOW){
hr++;
}
}
pbuttonB=cbuttonB;


if (cbuttonC != pbuttonC){
if (cbuttonC==LOW){
countdown=1;
}
}
pbuttonC=cbuttonC;



if (cbuttonD != pbuttonD){
if (cbuttonD==LOW){
countdown=0;
sec=3;
minu=0;
hr=0;
}
}
pbuttonD=cbuttonD;


  
unsigned long timer= millis();
 if(timer-pstimer > 1000){
   if(countdown==1){
        sec--;  
   }
   pstimer = timer;
 }  
 
if(sec==-1){
 sec=59; 
 minu--;
}

if(minu==-1){
 minu=59;
 hr--;
} 


if(hr==0 && minu==0 && sec==0){
  myservo.write(0); 
} 

else{
  myservo.write(180); 
}



    
//================================Time and mah

char szTime[11];
sprintf( szTime, "T%02d:%02d:%02d", hr, minu, sec );
lcd.setCursor(0,0);
lcd.print( szTime );


}

yep, computers are kinda funny about that, doing exactly what you tell them do

…except, as someone recently pointed out, going to Hell.