int llf = 6;
int hlf = 2;
int mtr = 3;
int pin4 = 4;
int pin5 = 5;
int pin13 = 13;
int start = 0;
int stop = 0;
int pmp = 0;
bool pmpf = 0;
bool test = 0;
bool fault =0;
bool faultb = 0;
unsigned long tmr2;
unsigned long time;
unsigned long LastTimeConditionWasFalse;
void setup() {
// put your setup code here, to run once:
pinMode(hlf, INPUT);
pinMode(llf, INPUT);
pinMode(mtr, OUTPUT);
pinMode(pin4 , INPUT);
pinMode (pin13, OUTPUT);
pinMode(pin5, OUTPUT);
}
void loop() { // put your main code here, to run repeatedly:
start = digitalRead(hlf);
stop = digitalRead(llf);
pmp = digitalRead(mtr);
pmpf = digitalRead (pin4);
if (start == LOW || stop == HIGH )
{
LastTimeConditionWasFalse = millis();
}
if (millis() - LastTimeConditionWasFalse >= 2000)
{
test = HIGH;
}
else {
test = LOW;
}
if (millis() - LastTimeConditionWasFalse >= 10000) {
digitalWrite (pin13 , HIGH );
}
else { digitalWrite (pin13 ,LOW );
}
if (start == LOW && stop == HIGH || start == LOW && stop == LOW || start == HIGH && stop == HIGH){
tmr2 = millis();
}
if (millis()- tmr2 >= 15000){
fault = HIGH;
}
else {
fault = LOW;
}
if(start == HIGH && stop == HIGH || stop == HIGH && pmp == HIGH || test == HIGH && fault == LOW )
{digitalWrite(mtr, HIGH);}
if(stop == LOW && test == LOW || fault == HIGH )
{digitalWrite(mtr, LOW);
}
if (fault == HIGH && pmpf == LOW){
faultb = HIGH;
}
if (faultb == HIGH){
digitalWrite(pin5, HIGH);
delay(250);
digitalWrite(pin5, LOW);
delay(250);
}
if (pmpf == HIGH){
faultb = LOW;
}
}