#define Pump 0
#define Button1State 1
#define Button2State 2
#define Button3State 3
#define Button4State 4
int startup_delay = 500;
int UpTime = 250;
int DownTime = 1000;
int i;
// setup function runs once after reset button pressed or powered on
void setup() {
pinMode(Pump, OUTPUT);
pinMode(Button1State, INPUT_PULLUP);
pinMode(Button2State, INPUT_PULLUP);
pinMode(Button3State, INPUT_PULLUP);
pinMode(Button4State, INPUT_PULLUP);
digitalWrite(Pump, LOW);
// delay(startup_delay);//wait some time
}
//loop function runs over and over forever
void loop() {
digitalWrite(Pump, LOW); //turn pump signal on
if (!digitalRead (Button1State)) {
digitalWrite(Pump, HIGH);
delay(UpTime);
digitalWrite(Pump, LOW);
delay(UpTime);
}
else if (!digitalRead (Button2State)) {
for (i=1; i<=2; i++){
digitalWrite(Pump, HIGH);
delay(UpTime);
digitalWrite(Pump, LOW);
delay(UpTime);
}}
else if (!digitalRead (Button3State)) {
for (i=1; i<=3; i++){
digitalWrite(Pump, HIGH);
delay(UpTime);
digitalWrite(Pump, LOW);
delay(UpTime);
}}
else if (!digitalRead (Button4State)) {
for (i=1; i<=4; i++){
digitalWrite(Pump, HIGH);
delay(UpTime);
digitalWrite(Pump, LOW);
delay(UpTime);
}}
else digitalWrite(Pump, LOW);
digitalWrite(Pump, LOW); //turn pump signal off
if (!digitalRead (Button1State)) delay(DownTime);
else if (!digitalRead (Button2State)) delay(DownTime);
else if (!digitalRead (Button3State)) delay(DownTime);
else if (!digitalRead (Button4State)) delay(DownTime);
else digitalWrite(Pump, LOW);
}