top of page

Arduino Smart Irrigation System


SOURCE CODE:

#include <AFMotor.h> //include motor shield library const int soilSensor = A1; //set soil moisture sensor to A0 int soilMoist; //create varible soilMoist AF_DCMotor motor(1); //set the water pump to motor void setup() { pinMode(soilSensor, INPUT); //soil moisture sensor is an input motor.setSpeed(200); //set the water pump speed Serial.begin(9600); //begin the serial monitor delay(1000); //delay 1 sec

}

void loop() {

soilMoist = analogRead(soilSensor); //read the soil moisture sensor Serial.println(soilMoist);

if(soilMoist > 400) { //if water levels are low and it is not raining motor.run(FORWARD); //turn pump on delay(2000); //for 2 seconds motor.run(RELEASE); //turn off the pump } else{ motor.run(RELEASE); //turn off the motor } delay(5000); //delay(28800000);//delay 8 hours }


Single post: Blog_Single_Post_Widget
bottom of page