-
Notifications
You must be signed in to change notification settings - Fork 0
/
Code-(arduino) Embeded C.txt
52 lines (41 loc) · 1011 Bytes
/
Code-(arduino) Embeded C.txt
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
#include <LiquidCrystal.h>
const int LM35 = A0;
const int motor = 13;
const int LedRed = 12;
const int LedGreen = 11;
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print("Smart Plant");
lcd.setCursor(0,1);
lcd.print("Irrigation System!");
pinMode(motor, OUTPUT);
pinMode(LedRed, OUTPUT);
pinMode(LedGreen, OUTPUT);
delay(2000);
lcd.clear();
lcd.print("Temperature= ");
lcd.setCursor(0,1);
lcd.print("Motor= ");
}
void loop() {
int value = analogRead(LM35);
float Temperature = value * 500.0 / 1023.0;
lcd.setCursor(6,0);
lcd.print(Temperature);
lcd.setCursor(11,1);
if (Temperature > 50){
digitalWrite(motor, HIGH);
digitalWrite(LedRed, HIGH);
digitalWrite(LedGreen, LOW);
lcd.print("ON ");
}
else {
digitalWrite(motor, LOW);
digitalWrite(LedRed, LOW);
digitalWrite(LedGreen, HIGH);
lcd.print("OFF");
}
delay(1000);
}