program doesn't work, need help in finding the bug

this part didn't run. led 13 didn't flash.

 if(milsec==10){
  stLEDf=!stLEDf; // 13 pin sec flasher
  sec++; // add 1 sec to sec
  milsec=0;
  
 }

here is the logic. is there any problem to this?

unsigned long timer= millis();
 if(timer-pstimer > 100){
   milsec++;
   miniTimer=!miniTimer;   
   pstimer = timer;
 }  
 
 
 if(milsec==10){
  stLEDf=!stLEDf; // 13 pin sec flasher
  sec++; // add 1 sec to sec
  milsec=0;
  
 }

here are Full code

int milsec=0;
int sec=0;
int minu=0;
int hr=0;

unsigned long pstimer=0;

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

int ledA=8;
int ledB=9;
int ledC=10;
int ledD=11;
int ledE=12;
int ledF=13;

int stLEDf=0;

int stLED[10]={0,0,0,0,0,0,0,0,0,0};

int mode=0; // 0 for sec counting; 1 for clock mode;
int set_time=0; // 0 for nothing; 1 for setting hr; 2 for setting minu.
int miniTimer=0; // 1/10 a sec minitimer

void setup() {  
  
pinMode(A2,INPUT_PULLUP); //buttonA
pinMode(A3,INPUT_PULLUP); //buttonB
pinMode(A4,INPUT_PULLUP); //buttonC 
pinMode(A5,INPUT_PULLUP); //buttonD

pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);

}

void loop() {

//----------------------------------------------------------------------------------  
//======= Start Button ==================================================================  
int cbuttonA=digitalRead (A2);  
int cbuttonB=digitalRead (A3); 
int cbuttonC=digitalRead (A4); 
int cbuttonD=digitalRead (A5); 

//buttonA//
if (cbuttonA != pbuttonA){
if(cbuttonA==LOW){     // buttonA
hr++;
}
}
pbuttonA=cbuttonA;

//buttonB//
if (cbuttonB != pbuttonB){
if(cbuttonB==LOW){            // buttonB
minu++;
}
}
else (digitalWrite (9, LOW));
pbuttonB=cbuttonB;

//buttonC//
if (cbuttonC != pbuttonC){
if (cbuttonC==LOW){           // buttonC
set_time++;
if(set_time==3) set_time=0;
}
}
pbuttonC=cbuttonC;


//buttonD//
if (cbuttonD != pbuttonD){
if (cbuttonD==LOW){           // buttonD
mode=!mode;
}
}
pbuttonD=cbuttonD;

//button D C//


//----------------------------------------------------------------------------------
//======= End button ===============================================================


//----------------------------------------------------------------------------------
//======= start timer ==============================================================
unsigned long timer= millis();
 if(timer-pstimer > 100){
   milsec++;
   miniTimer=!miniTimer;   
   pstimer = timer;
 }  
 
 
 if(milsec==10){
  stLEDf=!stLEDf; // 13 pin sec flasher
  sec++; // add 1 sec to sec
  milsec=0;
  
 }
//----------------------------------------------------------------------------------
//=======End timer =================================================================


//----------------
if(mode==0){

for(int x=0; x<=9; x++){
if(milsec%10==1){
stLED[x]=1;
}
}
}

//----------------




//----------------------------------------------------------------------------------
//======= start LED Code ==========================================================

if(stLED[0]==1){
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}

if(stLED[1]==1){
digitalWrite (ledA, HIGH);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}

if(stLED[2]==1){
digitalWrite (ledA, HIGH);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}

if(stLED[3]==1){
digitalWrite (ledA, HIGH);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, LOW);
digitalWrite (ledE, LOW);
}

if(stLED[4]==1){
digitalWrite (ledA, HIGH);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, LOW);
}

if(stLED[5]==1){
digitalWrite (ledA, HIGH);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, HIGH);
}

if(stLED[6]==1){
digitalWrite (ledA, LOW);
digitalWrite (ledB, HIGH);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, HIGH);
}

if(stLED[7]==1){
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, HIGH);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, HIGH);
}

if(stLED[8]==1){
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, HIGH);
digitalWrite (ledE, HIGH);
}

if(stLED[9]==1){
digitalWrite (ledA, LOW);
digitalWrite (ledB, LOW);
digitalWrite (ledC, LOW);
digitalWrite (ledD, LOW);
digitalWrite (ledE, HIGH);
}


//----------------------------------------------------------------------------------
//======= End LED Code ============================================================


























}

It is impossible to determine what your functions actually are. You seem to have a whole pile of code there which is not in any function.

michinyon:
It is impossible to determine what your functions actually are. You seem to have a whole pile of code there which is not in any function.

I just need pin 13 to go high and low every sec to flash the LED.

You have to write something (HIGH or LOW) to pin 13.

AWOL:
You have to write something (HIGH or LOW) to pin 13.

thank you. This is old code reused. I have that on my old code which I deleted accidentally when editing this new one. I was concentrating on the code for the LED sequences. It doesn't work also.

is there anything wrong with this? all led lighted up in this case. I need them to light up according to the sec in a sequence.

for(int x=0; x<=9; x++){
if(milsec%10==1){
stLED[x]=1;
}
}
unsigned long timer= millis();
 if(timer-pstimer > 100){
   milsec++;
   miniTimer=!miniTimer;   
   pstimer = timer;
 }  
 
 
 if(milsec==10){
  stLEDf=!stLEDf; // 13 pin sec flasher
  sec++; // add 1 sec to sec
  milsec=0;
  
 }


if(mode==0){

for(int x=0; x<=9; x++){
if(milsec%10==1){
stLED[x]=1;
}
}
}

Yeah, two problems, you don't actually write a high or low to pin 13, that I can see. And the other problem is that the code is neither inside, or apparently called by, your loop() function.