Arduino – Fuktsensor med LCD Vn.07

//HofstadNET Vn 0.7 Plant moisture sensor
//Info about the pin number
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
int moistureSensor = A0;
int OutputValue = 0;

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.7");
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);

//OutputValue = (SensorValue, SensorZero, SensorMax, 0, 100)
OutputValue = map(sensorValue, 270, 545, 100, 0);
Serial.println(sensorValue);

lcd.setCursor(10, 3);
lcd.print(sensorValue);
lcd.setCursor(16, 2);
lcd.print(OutputValue);
lcd.setCursor(19, 2);
lcd.print("%");

//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(1000);
}