#define POWERBUTTON 7
#define HEATER 5
#define WATERKRANE 4
#define POWERLED 6
#define WATERSENSOR 3
#define CLEANER 2
#define WATERPUMP 8
#define TIMERPUMP 300000 //5 min
void setup()
{
pinMode(POWERBUTTON, INPUT_PULLUP);
pinMode(WATERSENSOR, INPUT_PULLUP);
pinMode(HEATER, OUTPUT);
pinMode(POWERLED, OUTPUT);
pinMode(WATERKRANE, OUTPUT);
pinMode(CLEANER, OUTPUT);
pinMode(WATERPUMP, OUTPUT);
}
unsigned long int timer;
int state = 1;
void loop()
{
if(!digitalRead(POWERBUTTON)) //green button main power
{
delay(500);
digitalWrite(POWERLED, HIGH); //red led
if (digitalRead(WATERSENSOR)) //yelow button
{
digitalWrite(WATERKRANE, HIGH); //water krane on (yellow led)
while(digitalRead(WATERSENSOR));
digitalWrite(WATERKRANE, LOW); //water krane off (yellow led)
}
delay(500);
digitalWrite(HEATER, HIGH); //Heater on (cyan led)
timer = millis();
while (digitalRead(POWERBUTTON)) //Press powerbutton to continue
{
if(((millis()-timer)/500)%2) //blinling power led (red)
{
if (state) {digitalWrite(POWERLED, LOW);state=0;}
} else {if(!state)digitalWrite(POWERLED, HIGH);state=1;}
}
digitalWrite(POWERLED, HIGH);
delay(500);
timer = millis();
state = 1;
digitalWrite(WATERPUMP, HIGH); //pump on (blue led)
while (state) //working, powerbutton for abort
{
if(millis()-timer>TIMERPUMP||!digitalRead(POWERBUTTON))
{
state = 0;
digitalWrite(WATERPUMP, LOW); //pump off (blue led)
}
}
delay(500);
digitalWrite(CLEANER, HIGH); //Cleaner on (purple led)
delay(10000);
digitalWrite(CLEANER, LOW); //Cleaner off (purple led)
digitalWrite(HEATER,LOW); //Heater off (cyan led)
digitalWrite(POWERLED, LOW); //power off (red led)
delay(1000);
}
}