int PROBE= 1; int value= 0; int TIP120pin = 3; //for this project, int TIP120pin1 = 3 int ledState = LOW; // int ledState1 = LOW; unsigned long previousMillis = 0; // will store last time LED was updated unsigned long previousMillis1 = 0; long OnTime = 3600000; // milliseconds of on-time FAN modify here long OnTime1 = 3600000; long OffTime = 60000; // milliseconds of off-time FAN modify here long OffTime1 = 60000; int sensorPin = A0; // select the input pin int sensorValue = 0; // variable to store the value coming from the sensor void setup() { // set the digital pin as output: pinMode(5,OUTPUT); pinMode(TIP120pin, OUTPUT); // Set pin for output to control TIP120 Base pin pinMode(TIP120pin1, OUTPUT); // Set pin for output to control TIP120 Base pin pinMode(4, OUTPUT); pinMode(2, OUTPUT); //pin connected to the relay Serial.begin(9600); //sets serial port for communication } void loop() { // check to see if it's time to change the state of the FAN unsigned long currentMillis = millis(); if((ledState == HIGH) && (currentMillis - previousMillis >= OnTime)) { ledState = LOW; // Turn fan off digitalWrite(4,LOW);//tur off the relay previousMillis = currentMillis; // Remember the time digitalWrite(TIP120pin, ledState); // Update } else if ((ledState == LOW) && (currentMillis - previousMillis >= OffTime)) { ledState = HIGH; // turn fan on digitalWrite(4,HIGH);// turn on the relay previousMillis = currentMillis; // Remember the time digitalWrite(TIP120pin, ledState); // Update } //code for the light unsigned long currentMillis1 = millis(); if((ledState1 == HIGH) && (currentMillis1 - previousMillis1 >= OnTime1)) { ledState1 = LOW; // Turn fan off digitalWrite(2,LOW);//tur off the relay previousMillis1 = currentMillis1; // Remember the time digitalWrite(TIP120pin1, ledState1); // Update } else if ((ledState1 == LOW) && (currentMillis1 - previousMillis1 >= OffTime1)) { ledState1 = HIGH; // turn fan on digitalWrite(2,HIGH);// turn on the relay previousMillis1 = currentMillis1; // Remember the time digitalWrite(TIP120pin1, ledState1); // Update //code water pump value= analogRead(PROBE); value= value/100; //divided by 100 Serial.println(value); if(value<5) //modify here the value { digitalWrite(5, HIGH); } else { digitalWrite(5, LOW); } }