Flame detection and ignition with 3 attempts

I am trying to build a safety project for my burner. I somehow managed to shut down all system with no flame but I want my ignitor to try 3 time before it close down all system can some body direct me here is my code.

#define FLMD 2 //FLAME DETECTION
#define MSOL 7 //MAIN SOLINOID VALVE
#define PSOL 5 //POILET SOLINOID VALVE
#define IGNI 6 //IGNITOR UNIT

void setup() {
pinMode(FLMD,INPUT);//FLAME DETECTION
pinMode(MSOL,OUTPUT); //MAIN SOLINOID VALVE
pinMode(PSOL,OUTPUT);//POILET SOLINOID VALVE
pinMode(IGNI,OUTPUT); //IGNITOR UNIT

digitalWrite(FLMD,HIGH);
digitalWrite(MSOL,HIGH);
digitalWrite(PSOL,HIGH);
digitalWrite(IGNI,HIGH);

delay (2000);
digitalWrite(PSOL,LOW);
delay (3000);
digitalWrite(IGNI,LOW);
delay(5000);
digitalWrite(MSOL,LOW);
delay(2000);
}

void loop() {
if (digitalRead(FLMD) !=HIGH) {
digitalWrite(MSOL,HIGH);
digitalWrite(PSOL,HIGH);
digitalWrite(IGNI,HIGH);

} else {
digitalWrite(MSOL,LOW);
digitalWrite(PSOL,LOW);
digitalWrite(IGNI,LOW);
}

}

sketch_sep12a.ino (874 Bytes)

(deleted)

Thanks Peter for your response please let me know what is this time stage?

(deleted)

Peter I am not familiar with function. Can you explain a bit more. Thanks

Hello,
The method Peter-CAD-HST mentions can be found here:

I have not looked at your code, but I understand what Peter-CAD-HST posted, and I think that link will help you.

Randy