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;}
}