7 segment flickring

i want to make countdown clock with adjustable time and control some relays

and i want to use 2 displays seven segment and lcd 20*2

lcd is working fine but seven segment is flickering.

#include <LiquidCrystal.h>
#include <Bounce2.h>
#include "SevSeg.h"

#define BUTTON_PINs   9
#define LED_PIN       13
#define feedback      8
#define BUTTON_PINin  22
#define BUTTON_PINp   10
#define BUTTON_PINn   11
#define BUTTON_PINr   12
#define BUTTON_PINf   27
#define BUTTON_PINb   26
#define BUTTON_PIN60  25
#define BUTTON_PIN30  24
Bounce debouncers  = Bounce();
Bounce debouncerp  = Bounce();
Bounce debouncern  = Bounce();
Bounce debouncerr  = Bounce();
Bounce debouncerin = Bounce();
Bounce debouncerf  = Bounce();
Bounce debouncerb  = Bounce();
Bounce debouncer60 = Bounce();
Bounce debouncer30 = Bounce();
int S = 00;  // count seconds
int M = 60;   // count minutes
int H = 00;  // count hours

int ledState =      LOW;
int feedbackState = LOW;


//initialize the library with the numbers of the interface pins
LiquidCrystal lcd(2, 3,  4, 5, 6, 7); // pins connected to LCD
SevSeg sevseg; 
void setup()
{
 byte numDigits = 4;   
  byte digitPins[] = {34, 32, 30, 28};
  byte segmentPins[] = {36, 38, 40, 42, 44, 46, 48,37};
  bool resistorsOnSegments = false; // Use 'true' if on digit pins
  byte hardwareConfig = COMMON_ANODE; // See README.md for options
  
  sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments);
  sevseg.setBrightness(500);
  pinMode(50, OUTPUT);
  pinMode(51, OUTPUT);
  pinMode(52, OUTPUT);
  // pinMode(50, OUTPUT);
  lcd.begin(16, 2); //set up the LCD's number of columns and rows
  Serial.begin(9600);
  pinMode(BUTTON_PINs,  INPUT_PULLUP);
  pinMode(BUTTON_PINp,  INPUT_PULLUP);
  pinMode(BUTTON_PINn,  INPUT_PULLUP);
  pinMode(BUTTON_PINr,  INPUT_PULLUP);
  pinMode(BUTTON_PINin, INPUT_PULLUP);
  pinMode(BUTTON_PINf,  INPUT_PULLUP);
  pinMode(BUTTON_PINb,  INPUT_PULLUP);
  pinMode(BUTTON_PIN60, INPUT_PULLUP);
  pinMode(BUTTON_PIN30, INPUT_PULLUP);
  // After setting up the button, setup the Bounce instance :
  debouncers.attach(BUTTON_PINs);
  debouncers.interval(0);
  debouncerp.attach(BUTTON_PINp);
  debouncerp.interval(0);
  debouncern.attach(BUTTON_PINn);
  debouncern.interval(0);
  debouncerr.attach(BUTTON_PINr);
  debouncerr.interval(0);
  debouncerin.attach(BUTTON_PINin);
  debouncerin.interval(0);
   debouncerf.attach(BUTTON_PINf);
  debouncerf.interval(0);
   debouncerb.attach(BUTTON_PINb);
  debouncerb.interval(0);
   debouncer60.attach(BUTTON_PIN60);
  debouncer60.interval(0);
   debouncer30.attach(BUTTON_PIN30);
  debouncer30.interval(0);
  pinMode(LED_PIN, OUTPUT);
  pinMode(feedback, OUTPUT);
  digitalWrite(LED_PIN, ledState);
  digitalWrite(feedback, feedbackState);
}
void loop()
{
  
   
  lcd.setCursor(1, 0);
  lcd.print ("    ");
  // lcd.setCursor(10,1);
  //lcd.print(":");
  lcd.setCursor(13, 1);
  lcd.print(":");
  debouncers .update();
  debouncerp .update();
  debouncern .update();
  debouncerr .update();
  debouncerin.update();
  debouncerf .update();
  debouncerb .update();
  debouncer60.update();
  debouncer30.update();

  // Get the updated value :
  int values  = debouncers .read();
  int valuep  = debouncerp .read();
  int valuen  = debouncern .read();
  int valuer  = debouncerr .read();
  int valuein = debouncerin.read();
  int valuef  = debouncerf .read();
  int valueb  = debouncerb .read();
  int value60 = debouncer60.read();
  int value30 = debouncer30.read();
  if ( valuep == HIGH ) {
    M = (M + 1);
   // delay(250);
  }

  if ( valuen == HIGH ) {
    M = (M - 1);
  //  delay(250);
  }
  if ( value60 == HIGH ) {
    M =60;
  }
  if ( value30 == HIGH ) {
    M =30;
  }
  if ( valuef == HIGH ) {
    digitalWrite(51, LOW);
    digitalWrite(52, LOW);
    
  }
  else if ( valueb == HIGH ) {
    digitalWrite(51, HIGH);
    digitalWrite(52,HIGH);
  }

  if ( debouncers.fell() ) {

    // Toggle LED state :
    ledState = !ledState;
    digitalWrite(LED_PIN, ledState);
    feedbackState = !feedbackState;
    digitalWrite(feedback, feedbackState);

  }
  if ( feedbackState == HIGH && M >= 0 && S >= 0 )
  {

    lcd.setCursor(0, 1);
    lcd.print("TIME LEFT:");
    S--;
    delay(1000);

  }
  else {
    S;

    lcd.setCursor(0, 1);
    lcd.print("   READY  ");
  }


  if (S < 0)
  {
    M--;
    S = 59;
  }
  if (M < 0)
  {
    H--;
    M = 00;
  }
  if (H < 0)
  {
    H = 00;
    M = 00;
    S = 00;
  }
  if (M > 9)
  {
    lcd.setCursor(11, 1);
    lcd.print(M);
     sevseg.setNumber(M);
  sevseg.refreshDisplay();
  }
  else
  {
    lcd.setCursor(11, 1);
    lcd.print("0");
    lcd.setCursor(12, 1);
    lcd.print(M);
     sevseg.setNumber(M);
  sevseg.refreshDisplay();
    lcd.setCursor(13, 1);
    lcd.print(":");
  }

  if (S > 9)
  {
    lcd.setCursor(14, 1);
    lcd.print(S);
  }
  else
  {
    lcd.setCursor(14, 1);
    lcd.print("0");
    lcd.setCursor(15, 1);
    lcd.print(S);
    lcd.setCursor(16, 1);
    lcd.print(" ");
  }

  if (H > 9)
  {
    //lcd.setCursor(8,1);
    //lcd.print (H);
  }
  else
  {
    //lcd.setCursor(8,1);
    // lcd.print("0");
    // lcd.setCursor(9,1);
    // lcd.print(H);
    // lcd.setCursor(10,1);
    //lcd.print(":");
  }
  if (M == 0 && S == 0) {
    digitalWrite(50, HIGH);
  }
  else if (valuein == LOW) {
    digitalWrite(50, HIGH);
  }
  else if (valuein == LOW) {
    digitalWrite(50, HIGH);
  }

  else
  {
    digitalWrite(50, LOW);
  }

  if ( valuer == HIGH ) {
    digitalWrite(50, LOW);
  }
  else
  {digitalWrite(50, HIGH);
  }

  
 



}

http://forum.arduino.cc/index.php?actio … ach=202800