Hello! i need some help..
im making an automatic irrigation system and everthing was working fine.
But then i decided i wan to to add 2 buttons. If any of them is on (High) the system works, if not it is just waiting.
When i run it, the logic works but in some cases the display doesnt look well. It looks dimmed and washed out with out the complete word.
im using 12C library
The code:
#include <Wire.h>
#include <LCD.h>
#include <hd44780.h>
#include <LiquidCrystal_I2C.h>
int pushmanual = 1;
int botontiempo = 2;
int M_Sensor = A0;
int SensorNivelAgua = 7;
int RelayOn = 13;
int LedLevel = 11;
LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7); // 0x27 is the I2C bus address for an unmodified backpack
void setup()
{
// activate LCD module
lcd.begin (16,2); // for 16 x 2 LCD module
lcd.setBacklightPin(3,POSITIVE);
lcd.setBacklight(HIGH);
lcd.clear();
//PinModes
pinMode(RelayOn, OUTPUT);
pinMode(LedLevel, OUTPUT);
pinMode(pushmanual, INPUT);
pinMode(botontiempo, INPUT);
pinMode(SensorNivelAgua, INPUT);
//start Message
lcd.setCursor(0,0);
lcd.print("INICIANDO..");
lcd.setCursor(0,1);
lcd.print("V 0.1");
delay(3000);
lcd.clear();
}
void loop()
{
if (digitalRead(botontiempo)==LOW && digitalRead(pushmanual)==LOW ) //If it is not time or manual boton off
{
lcd.clear();
lcd.setBacklight(HIGH);
lcd.setCursor(0,1);
lcd.print("BOTONES OFF");
digitalWrite(RelayOn, HIGH); //pump off
digitalWrite(LedLevel, LOW); // LedLevel Off
}
else
{
lcd.setBacklight(HIGH);
int Moisture = analogRead(M_Sensor); //Read Moisture Sensor Value
lcd.clear();
lcd.setCursor(0,0);
lcd.print("ES HORA");
if (Moisture> 700) // for dry soil
{
lcd.setCursor(10,0);
lcd.print("TIERRA");
lcd.setCursor(10,1);
lcd.print(" SECA ");
if (digitalRead(SensorNivelAgua)==LOW) //test the availability of water in storage - there is water
{
lcd.clear();
// lcd.setCursor(0,1);
// lcd.print("PUMP:ON ");
digitalWrite(RelayOn, LOW); //turns on pump
digitalWrite(LedLevel, LOW); //turns off LED
}
else
{
digitalWrite(RelayOn, HIGH); //turns off pump
lcd.setCursor(0,1);
lcd.print("SIN AGUA"); // theres no water
digitalWrite(LedLevel, HIGH); //Blinks LED
delay(1000);
digitalWrite(LedLevel, LOW);
delay(1000);
}
}
/*
if (Moisture>= 300 && Moisture<=700) //for Moist Soil
{
lcd.setCursor(10,0);
lcd.print("TIERRA");
lcd.setCursor(10,1);
lcd.print("HUMEDA");
digitalWrite(RelayOn,HIGH);
digitalWrite(LedLevel, LOW);
lcd.setCursor(0,1);
lcd.print("PUMP:OFF");
}
if (Moisture < 300) // For Soggy soil
{
lcd.setCursor(10,0);
lcd.print("TIERRA");
lcd.setCursor(10,1);
lcd.print("MOJADA");
digitalWrite(RelayOn,HIGH);
digitalWrite(LedLevel, LOW);
lcd.setCursor(0,1);
lcd.print("PUMP:OFF");
}
*/
}
}
The images:

