Newbie needing help Timers issue.

Hi

I need to some how only request the timer on the interval to start when the High pushbutton has been pressed or for it to stay reset after Low Pushbutton.

Any advice on how I could do this would be much appreciated!!!!

START OF CODE:

//Buttons simulating level Switch
const int highL = 3;
const int lowL = 2;

//LEDs simulating Pumps & Alarm
const int Pump1 = 7;
const int Alarm = 6;
const int Pump2 = 5;

unsigned long previousMillis = 0;
unsigned long currentMillis;

//Switch State set to Low
int switchState = 0;
int interval = 10000;

void setup() {

// initialize the digital pin as an output.
pinMode(Pump1, OUTPUT);
pinMode(Alarm, OUTPUT);
pinMode(Pump2, OUTPUT);
pinMode(highL, INPUT_PULLUP);
pinMode(lowL, INPUT_PULLUP);
}

void loop() {

switchState = digitalRead(highL);

//If Level is High Output Required.
if(switchState== HIGH){
digitalWrite(Pump1,HIGH);
}

switchState = digitalRead(lowL);

//If Level is Low no Output Required.

if(switchState== HIGH){

digitalWrite(Pump1,LOW);
digitalWrite(Pump2,LOW);}

unsigned long currentMillis = millis();

if ((unsigned long)(currentMillis - previousMillis) >= interval) {

digitalWrite(Pump2, !digitalRead(Pump2));
previousMillis = currentMillis;}

}

need to some how only request the timer on the interval to start when the High pushbutton has been pressed or for it to stay reset after Low Pushbutton.

Set the previousMillis to the current time only when you see pushbutton pressed, not in the time out section.

You need the variable interval to be the same unsigned long as the time variables and you don’t need a cast in the if statement.

Not sure if this is what you meant but now the red LED won't come on anymore. :o

switchState = digitalRead(lowL);
//If Level is Low no Output Required.
if(switchState== HIGH){

digitalWrite(Pump1,LOW);
digitalWrite(Pump2,LOW);}

//when interval has ran out (2seconds) turn on pump2

if ((currentMillis - previousMillis) >= interval) {

digitalWrite(Pump2, !digitalRead(Pump2));
previousMillis = currentMillis;}

}

}

Not sure if this is what you meant

It is not what I said, in any way.

Set the previousMillis to the current time only when you see pushbutton pressed, not in the time out section.

I do not see you doing that.

note that your buttons should be wired between input and ground and when pushed they will read LOW.

Please read this:-
How to use this forum
Because your post is breaking the rules about posting code.

Ok ill have a look, I'm totally new to this so sorry if I have come across as brain dead!