Using millis() on Pin HIGH to turn on another Pin HIGH

I am trying to trip a alarm when pump goes high for more than 5 minutes.
This is my code, but I don't know how to set the millis() so that if the pump pin goes high
for more than 5 minutes it would set the alarm pin high.
any help would be greatly appreciated.

[code]


int topOpticalSensorPin = 0;  
int topOpticalSensorReading;  

#define pump  7
#define alarm  8
int pump_off = 100;  // sensor in water, is around 3
int pump_on = 400;  // sensor out of water, is around 982

void setup(void) {

  pinMode(pump, OUTPUT);  
  digitalWrite(pump, LOW);  // keeps pump off, at startup
  pinMode(alarm, OUTPUT);  
  digitalWrite(alarm, LOW);
}

void loop(void) {
  topOpticalSensorReading = analogRead(topOpticalSensorPin); // take a reading from the optical sensor pin
 
  if (topOpticalSensorReading < pump_off) {
     digitalWrite(pump, LOW);   // turn off pump
  }  else if (topOpticalSensorReading > pump_on){
     digitalWrite(pump, HIGH);   // turn on pump
  
    }

}

[/code]

Still not working

[code]


int topOpticalSensorPin = 0;  
int topOpticalSensorReading;  

#define pump  7
#define alarm  8
int pump_off = 100;  // sensor in water, is around 3
int pump_on = 400;  // sensor out of water, is around 982
unsigned long whenThePumpTurnedOn;

void setup(void) {

  pinMode(pump, OUTPUT);  
  digitalWrite(pump, LOW);  // keeps pump off, at startup
  pinMode(alarm, OUTPUT);  
  digitalWrite(alarm, LOW);
}

void loop(void) {
  topOpticalSensorReading = analogRead(topOpticalSensorPin); // take a reading from the optical sensor pin
 
  if (topOpticalSensorReading < pump_off) {
     digitalWrite(pump, LOW);   // turn off pump
  }  else if (topOpticalSensorReading > pump_on){
     digitalWrite(pump, HIGH);   // turn on pump
     whenThePumpTurnedOn = millis();
    }
  if (digitalRead(pump == HIGH))
{
  if(millis() - whenThePumpTurnedOn >= 5000UL){  // Pump has been on for howLongYouWannaWait time.  
  digitalWrite(alarm, HIGH);
  }
}
}

[/code]

Use to format the code.
What's not working!

.

Thanks for the reply,
Alarm pin8 is not going high after the stated millis() time.

This

  if (digitalRead(pump == HIGH))

reads pin 0 or 1.

whenThePumpTurnedOn = millis();

Is resetting every time through loop(), you need a "timing" flag thats set when pump starts and reset when pump stops.

I have been working on the code for a week, trying ways to make the code work, maybe if I can get
some useful advice, to be pointed in the right direction.

maybe if I can get
some useful advice

Maybe if you posted your current code, and explain what it actually does and how that differs from what you want...