#define Button1State 1
#define Button2State 2
#define Button3State 3
#define Button4State 4
#define Button5State 5
int startup_delay = 500;
int UpTime = 250;
int DownTime = 250;
// setup function runs once after reset button pressed or powered on
void setup() {
pinMode(PB0, OUTPUT);
pinMode(PB1, INPUT_PULLUP);
pinMode(PB2, INPUT_PULLUP);
pinMode(PB3, INPUT_PULLUP);
pinMode(PB4, INPUT_PULLUP);
pinMode(PB5, INPUT_PULLUP);
delay(startup_delay);//wait some time
}
//loop function runs over and over forever
void loop() {
digitalWrite(PB0, LOW); //turn pump signal on
if (digitalRead (Button1State)) {
digitalWrite(PB0, HIGH);
delay(UpTime);}
else if (digitalRead (Button2State)) {
digitalWrite(PB0, HIGH);
delay(UpTime*2);}
else if (digitalRead (Button3State)) {
digitalWrite(PB0, HIGH);
delay(UpTime*3);}
else if (digitalRead (Button4State)) {
digitalWrite(PB0, HIGH);
delay(UpTime*4);}
else if (digitalRead (Button5State)) {
digitalWrite(PB0, HIGH);
delay(UpTime*5);}
else digitalWrite(PB0, LOW);
digitalWrite(PB0, 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 if (digitalRead (Button5State)) delay(DownTime);
else digitalWrite(PB0, LOW);
}