Last active
May 19, 2019 06:00
-
-
Save littledivy/0424e70a37d84deaa8deea9417a08730 to your computer and use it in GitHub Desktop.
Arduino Automatic Plant Watering System Code For Digital Pin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int digitalSensor = 2; | |
int pumpPin = 8; //relay pin | |
int sensorValue = 0; | |
long pumpDelay = 60L * 1000L * 30L; | |
long pumpingDuration = 60L * 1000L * 5L; | |
void setup() { | |
pinMode(digitalSensor, INPUT); | |
pinMode(pumpPin, OUTPUT); | |
digitalWrite(pumpPin, HIGH); | |
//Serial.begin(9600); | |
} | |
void loop() { | |
sensorValue = digitalRead(digitalSensor); | |
Serial.print("Moisture Value = " ); | |
Serial.println(sensorValue); | |
if(sensorValue == HIGH){ | |
digitalWrite(pumpPin,LOW); | |
//digitalWrite(LED_BUILTIN, HIGH); | |
delay(pumpingDuration); | |
digitalWrite(pumpPin, HIGH); | |
} | |
delay(pumpDelay); // 1hour | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment