Counter still running

hi guys i need help with my codes if i press the StartButton the counter working fine but if i press the PauseButton i need it to press 3 - 5 time to make my counter pause. i dont know what is the problem in my code.

// Button pin Settings
int StartPin = 12;
int PausePin = 13;
int StartButton = 0;
int PauseButton = 0;

// Default Counter
int Counter = 24;
int Running = false;

void setup(){  

  pinMode(StartPin , INPUT_PULLUP);
  pinMode(PausePin, INPUT_PULLUP);

}

void loop() {
  Count();
  Start();
  Pause();
  StartButton = digitalRead(StartPin);
  PauseButton = digitalRead(PausePin);

  if (Running == true && Counter > 0) {
      delay(1000);
      Counter --;  
    }
}
void Start() {
  if (StartButton == LOW){
    Running = true;
  }
}
void Pause(){
  if (PauseButton == LOW){
    Running = false;
  }
}

During the execution of this statement:

delay(1000);

your pause button will be unresponsive.

what should i do?

Hi,
Look in the Arduino IDE, Examples for "Blink without Delay".

It will show you how to use milli function to create a "delay" without blocking yor code.

Tom... :slight_smile:

its work! thank Tom... :smiley: