-
Notifications
You must be signed in to change notification settings - Fork 0
/
Automate Gardening System.ino
65 lines (63 loc) · 1.52 KB
/
Automate Gardening System.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
int pump = 7; //water pump pin
int sensor = A0; //Analog sensor pin
int standard = 200; //standard analog moisture reading.
int lowmoisture = 1; //low moisture value.
int highmoisture = 500; // High moisture value.
int moisture; //moisture reading will be store in this.
int percentage; //percentage calculate.
int count = 0;
int dcount = 0;
int led = 13;
void setup()
{
pinMode(pump, OUTPUT);
pinMode(sensor, INPUT);
digitalWrite(pump, HIGH);
digitalWrite(led, HIGH);
Serial.begin(9600);
}
void loop()
{
if (count < 3) {
Serial.print(count);
Serial.print("\n");
moisture = analogRead(sensor);
Serial.print(moisture);
Serial.print("\n");
if (moisture < standard)
{
Serial.print("Low moisture leval :");
percentage = map(moisture, lowmoisture, highmoisture, 0, 100);
Serial.print(percentage);
Serial.print("%");
Serial.print("\n");
digitalWrite(pump, LOW); // motor turn on
digitalWrite(led, HIGH);
delay(5000);
digitalWrite(pump, HIGH); // motor turn off
digitalWrite(led, LOW);
delay(100000);
count++;
}
else
{
Serial.print("High moisture leval :");
percentage = map(moisture, lowmoisture, highmoisture, 0, 100);
Serial.print(percentage);
Serial.print("%");
Serial.print("\n");
count = 0;
if (moisture > standard) {
digitalWrite(pump, HIGH);
}
delay(1000);
}
}
else {
delay(1000000);
dcount++;
if (dcount == 4) {
count = 0;
}
}
}