How to simulate a time delay relay

OK Toby.

It is quite a long story. (Sorry for being complicated).
The goal is to translate audio signals to optical signals.
The first thing i'm trying is to make a optical heart-beat checker. It is a medical project I'm trying with my brother (who is a doctor). The second step wil be to dedect breathing noise.
I made a amplifier filter to take the low frequency, and move it around the 2,5V on one of the inputs. I was able to display the sound on 8 LED's. However the LED's also display the background noise.
So I try to make them to react on either the positive or negative side of long wave. (Low frequency heart beat).
That is were I need the time delay for. The LED's should only react to a long wave.
Below some messy attempts. I try with "Level_LED1" first.

/*
  TubeChecker software.
  Use anelog inputs to analize hartbeat and breathing sounds, and than dispaying the result usin LED's.
  Writen by nicolaas Hartman, ENINN.
  V0_2 modifications:
  Make heartbeat signal more sensitive.
  V0_3 modifications:
  Time delay to filter out low frequency
  V0_4 modifications:
  New experimental Time delay to filter out low frequency
 */

// These constants won't change.  They're used to give names
// to the pins used:
const int HeartBeat = A0;  // Analog input pin that the low frequency filter is attached to
const int BreathNoise = A1; // Analog input pin that the breath noise filter is attached to
const int Choice = A2; // Analog input pin to choose between heart or breath display
const int Level_LED1 = 2;
const int Level_LED2 = 3;
const int Level_LED3 = 4;
const int Level_LED4 = 5;
const int Level_LED5 = 6;
const int Level_LED6 = 7;
const int Level_LED7 = 9;
const int Level_LED8 = 10;

int HeartValue = 0;        // value read from the low frequency filter
int BreathValue = 0;        // value read from the breath noise filter
int DisplayMode = 0;        // 1st value read from the mode selection input

void setup() {
  // initialize pin modes
  pinMode(Level_LED1, OUTPUT);
  pinMode(Level_LED2, OUTPUT);
  pinMode(Level_LED3, OUTPUT);
  pinMode(Level_LED4, OUTPUT);
  pinMode(Level_LED5, OUTPUT);
  pinMode(Level_LED6, OUTPUT);
  pinMode(Level_LED7, OUTPUT);
  pinMode(Level_LED8, OUTPUT);
  // initialize serial communications at 9600 bps:
  Serial.begin(9600); 
}

void loop() {
  // read the low frequency in value:
  HeartValue = analogRead(HeartBeat);            
  // read the breath filter in value:
  BreathValue = analogRead(BreathNoise);
  // read the mode choice input:
  DisplayMode = analogRead(Choice);
  
  // Map the heartbeat to the level LED's:
  unsigned long startTime=millis();
char high=1;

while(millis()<startTime+20)
{
   high &= (analogRead(HeartValue)>522);
}
if(high)
   digitalWrite(Level_LED1,HIGH);
else if (HeartValue < 522);
   digitalWrite(Level_LED1,LOW);
  
  
  if (HeartValue > 542 || HeartValue < 481)
{   
  digitalWrite(Level_LED2, HIGH);
}
else if (HeartValue < 542 || HeartValue > 481)
{     
  digitalWrite(Level_LED2, LOW);
}
  if (HeartValue > 562 || HeartValue < 461)
{
  digitalWrite(Level_LED3, HIGH);
}
else if (HeartValue < 562 || HeartValue > 461)
{
  digitalWrite(Level_LED3, LOW);
}
  if (HeartValue > 582 || HeartValue < 441)
{
  digitalWrite(Level_LED4, HIGH);
}
else if (HeartValue < 582 || HeartValue > 441)
{
  digitalWrite(Level_LED4, LOW);
}
  if (HeartValue > 602 || HeartValue < 421)
{
  digitalWrite(Level_LED5, HIGH);
}
else if (HeartValue < 602 || HeartValue > 421)
{
  digitalWrite(Level_LED5, LOW);
}
  if (HeartValue > 622 || HeartValue < 401)
{
  digitalWrite(Level_LED6, HIGH);
}
else if (HeartValue < 622 || HeartValue > 401)
{
  digitalWrite(Level_LED6, LOW);
}
  if (HeartValue > 642 || HeartValue < 381)
{
  digitalWrite(Level_LED7, HIGH);
}
else if (HeartValue < 642 || HeartValue > 381)
{
  digitalWrite(Level_LED7, LOW);
}
  if (HeartValue > 662 || HeartValue < 361)
{
  digitalWrite(Level_LED8, HIGH);
}
else if (HeartValue < 662 || HeartValue > 361)
{
  digitalWrite(Level_LED8, LOW);
}
  
  // print the results to the serial monitor:
  Serial.print("Heart = " );                       
  Serial.println(HeartValue);    
  Serial.print("Breath = " );                       
  Serial.println(BreathValue);
  Serial.print("Mode = ");      
  Serial.println(DisplayMode);   
  
  // wait 2 milliseconds before the next loop
  // for the analog-to-digital converter to settle
  // after the last reading:
  delay(2);                     
}