merging two looping codes

Hi guys

I have a code to counts whenever the microphone detects a sound.
I have another code that counts down 10 minutes.
I want an LCD to display both time and the counter at each rows.
I don’t really understand how I can apply the blink without example for my case.
What do I have to do?

microphone countdown

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int microphonePin= 1; //the microphone positive terminal will connect to analog pin A0 to be read
int sample; //the variable that will hold the value read from the microphone each time
int counter = 300;
int currentState = 0;
int previousState = 0;
const int threshold= 0;//the microphone threshold sound level at which the LED will turn on

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(8, 2);
  // Print a message to the LCD.
  lcd.print("countdown");
  pinMode (microphonePin, INPUT);//sets digital pin 13 as output
  Serial.begin(9600); //sets the baud rate at 9600 so we can check the values the microphone is obtaining on the Serial Monitor

}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(counter);
  sample= analogRead(microphonePin); //the arduino takes continuous readings from the microphone
delay(100);
if (sample > threshold)
{
currentState = 1;
delay (100); //LED stays on for a half a second
}
else{ 
currentState = 0;
delay (10); //LED stays on for a half a second
}
if (currentState ==1){counter = counter - 1;}
Serial.println(counter);}

10 min countdown

#include <LiquidCrystal.h>
 //www.brilliantlyeasy.com/ 
 
int hours = 0; // start hours
int minutes = 10; //start min
int seconds = 0; //start seconds
 
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
}
 
void loop() {
 lcd.begin(16, 2);
 lcd.print("Count Down Timer ");
 
 // lcd.scrollDisplayLeft();
 // wait a bit:
 delay(150);
 
 while (hours > 0 || minutes > 0 || seconds >= 0) {
 
 lcd.setCursor(4, 2);
 
 (hours < 10) ? lcd.print("0") : NULL;
 lcd.print(hours);
 lcd.print(":");
 (minutes < 10) ? lcd.print("0") : NULL;
 lcd.print(minutes);
 lcd.print(":");
 (seconds < 10) ? lcd.print("0") : NULL;
 lcd.print(seconds);
 lcd.display();
 stepDown();
 delay(1000);
 }
}
 
void stepDown() {
 if (seconds > 0) {
 seconds -= 1;
 } else {
 if (minutes > 0) {
 seconds = 59;
 minutes -= 1;
 } else {
 if (hours > 0) {
 seconds = 59;
 minutes = 59;
 hours -= 1;
 } else {
 trigger();
 }
 }
 }
}
 
void trigger() {
 lcd.clear(); // clears the screen and buffer
 lcd.setCursor(5, 1); // set timer position on lcd for end.
 
 lcd.println("END ");
 delay(1000);
 
 lcd.display();}

You'll have to rethink your countdown code. You can't trap it in that while loop. Just use the Blink Without Delay style out in the normal loop. On each pass of loop see if it has been 1 second since the last time you updated the time on the screen and if so then update it and add a second to the variable that track the last time it was updated. Then after that in loop check your microphone.

// include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int MicrophonePin = A1; //the microphone positive terminal will connect to analog pin A0 to be read
int Counter = 300;

unsigned long PreviousTime;
int Minutes = 10; //start min
int Seconds = 0; //start seconds

//the microphone threshold sound level
const int THRESHOLD = 0;


void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(8, 2);
  lcd.clear(); // clears the screen and buffer

  // Print a message to the LCD.
  lcd.print("countdown");

  Serial.begin(9600); //sets the baud rate at 9600 so we can
  // check the values the microphone is obtaining on the Serial Monitor

  PreviousTime = millis();
}

void loop() {
  //the arduino takes continuous readings from the microphone
  if (analogRead(MicrophonePin) > THRESHOLD) {
    Counter--;
    lcd.setCursor(0, 1);
    lcd.print(Counter);
    Serial.println(Counter);
  }

  if (millis() - PreviousTime >= 1000) {
    PreviousTime += 1000;
    stepDown();  // Another second has passed

    if (Minutes > 0 || Seconds >= 0) {
      lcd.setCursor(4, 2);  // Line 3 of 8x2 display?!?

      if (Minutes < 10)
        lcd.print("0");
      lcd.print(Minutes);
      lcd.print(":");
      if (Seconds < 10)
        lcd.print("0");
      lcd.print(Seconds);
      lcd.display();
    } else {
      lcd.setCursor(5, 1); // set timer position on lcd for end.
      lcd.println("END ");
      lcd.display();
      while (1) {}  // Freeze the sketch here
    }
  }
}

void stepDown() {
  if (Seconds > 0) {
    Seconds--;
  } else {
    if (Minutes > 0) {
      Seconds = 59;
      Minutes--;
    }
  }
}