//PIN INPUT
const int pb = 1; //PUSH BUTTON
//PIN OUTPUT
const int led = 2; //LED
const int mt1 = 3; //DC MOTOR 1(CW)
const int pmp = 4; //WATER PUMP
const int mt2 = 5; //AC MOTOR 2
const int mt3 = 6; //AC MOTOR 3
const int fan = 7; //FAN
const int mt4 = 8; //DC MOTOR 4(CCW)
void setup()
{
//INPUT SETUP
pinMode(pb, INPUT);
//OUTPUT SETUP
pinMode(led, OUTPUT);
pinMode(mt1, OUTPUT);
pinMode(pmp, OUTPUT);
pinMode(mt2, OUTPUT);
pinMode(mt3, OUTPUT);
pinMode(fan, OUTPUT);
pinMode(mt4, OUTPUT);
}
void loop()
{
int pbState = digitalRead(pb);
if (pbState == HIGH)
{
//LED and motor ON simultaneously
digitalWrite(led, HIGH);
digitalWrite(mt1, HIGH);
//Delay for 2s
delay(2000);
digitalWrite(led, LOW);
//Delay for 58s
delay(58000);
digitalWrite(mt1, LOW);
//Turn on other devices
digitalWrite(pmp, HIGH);
digitalWrite(mt2, HIGH);
digitalWrite(mt3, HIGH);
digitalWrite(fan, HIGH);
//Delay for 150s
delay(150000);
//Turn off other devices
digitalWrite(pmp, LOW);
digitalWrite(mt2, LOW);
digitalWrite(mt3, LOW);
digitalWrite(fan, LOW);
//Motor turn ON
digitalWrite(mt4, HIGH);
delay(20000);// Delay 20s
digitalWrite(mt4, LOW);
}
}