Académique Documents
Professionnel Documents
Culture Documents
61
APPENDICES B
62
63
APPENDICES D
64
APPENDICES E
SOURCE CODE
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
int val; //This variable stores the value received from Soil moisture sensor.
void setup() {
lcd.backlight();
Serial.begin(9600);
lcd.begin();
lcd.setCursor(0, 0);
lcd.print("Automatic Plant");
lcd.setCursor(0, 1);
lcd.print("Watering System");
delay(4000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Calibrating");
if (i == 4)
65
lcd.setCursor(0, 1);
lcd.print(".");
else lcd.print(".");
delay(200);
lcd.setCursor(5, 1);
lcd.print("done");
delay(1000);
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("SENSOR ACTIVE");
delay(1500);
pinMode(A0,INPUT); //Set pin 8 as input pin, to receive data from Soil moisture sensor.
while (! Serial);// wait for serial port to connect. Needed for native USB
Serial.println("Speed 0 to 255");
66
void loop()
int speed = Serial.parseInt(); // to read the number entered as text in the Serial Monitor
if(val == LOW)
digitalWrite(5, LOW); //if soil moisture sensor provides LOW value send LOW value to
lcd.setCursor(0,0);
lcd.setCursor(0,1);
lcd.print("MOISTURE: WET");
delay(3000);
else
67
digitalWrite(5, HIGH); //if soil moisture sensor provides HIGH value send HIGH value
lcd.setCursor(0,0);
lcd.setCursor(0,1);
lcd.print("MOISTURE: DRY");
delay(3000);
delay(400); //Wait for few second and then continue the loop.
68