-
Notifications
You must be signed in to change notification settings - Fork 0
/
Soil.ino
47 lines (44 loc) · 991 Bytes
/
Soil.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
// # Soil Monitoring
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.clear();
pinMode(2, OUTPUT);
digitalWrite(2, HIGH);
delay(1000);
lcd.setCursor(0, 0);
lcd.print("CROP IRRIGATION");
lcd.setCursor(0, 1);
lcd.print("SYSTEM IS ON ");
lcd.print("");
delay(3000);
lcd.clear();
}
void loop() {
int value = analogRead(A0);
Serial.println(value);
if (value > 950) {
digitalWrite(2, LOW);
lcd.setCursor(0, 0);
lcd.print("NPK SENSOR IS ON");
} else {
digitalWrite(2, HIGH);
lcd.setCursor(0, 0);
lcd.print("NPK SENSOR IS ON");
}
if (value < 300) {
lcd.setCursor(0, 1);
lcd.print("Moisture : HIGH");
} else if (value > 300 && value < 950) {
lcd.setCursor(0, 1);
lcd.print("N 72");
lcd.print(" P 39");
lcd.print(" K 25");
} else if (value > 950) {
lcd.setCursor(0, 1);
lcd.print("Moisture : LOW ");
}
}