Arduino – Fuktsensor med LCD Vn.06

Fuktsensor med lcd. Til bruk av måling av fuktighet i potteplanter 

Her er kode som jeg har skrevet.

//HofstadNET Vn 0.6 Plant moisture sensor
//Info about the pin number
#include < LiquidCrystal.h > 
LiquidCrystal lcd(12, 11, 10, 9, 8, 7); 
int moistureSensor = A0; 
void setup() { 
// Serial Begin so we can get the serial data 
Serial.begin(9600); 
//--------------------LCD SETUP---------------------- 
// set up the LCD's number of columns and rows (x, y): 
lcd.begin(20, 4); delay(1); 
// Print a message to the LCD. 
lcd.setCursor(0,0); 
lcd.print(" HofstadNET Vn0.6"); 
lcd.setCursor(0, 1); 
lcd.print("Data from Chilli"); 
lcd.setCursor(0, 2); 
lcd.print("Moist:"); 
lcd.setCursor(0, 3); 
lcd.print("Raw data:"); 
} 
void loop() { 
// Read the analog input value on pin 0: 
int sensorValue = analogRead(moistureSensor); 
Serial.println(sensorValue); 
lcd.setCursor(10, 3); 
lcd.print(sensorValue); 
// Print the sensorValue in monitor 
Serial.println(sensorValue); 

//Moisture is LOW, start to water it 
if (sensorValue >= 430 && sensorValue < 1024) 
{ 
lcd.setCursor(7, 2); 
lcd.print(" "); 
lcd.setCursor(7, 2); 
lcd.print("LOW"); 
} 

//Moisture is Medium, maybe the perfect moisture? 
else if (sensorValue >= 350 && sensorValue < 430) 
{ 
lcd.setCursor(7, 2); 
lcd.print(" "); 
lcd.setCursor(7, 2); 
lcd.print("Medium"); 
} 
//Moisture is Very HIGH, dont drown the plant 
else if (sensorValue >= 0 && sensorValue < 350)
{
lcd.setCursor(7, 2);
lcd.print("             ");
lcd.setCursor(7, 2);
lcd.print("High");
}
delay(5000);
}