Button turns LCD OFF but not ON.. SomeOne Help PLease

i need some help with this code .. I can get the LCD to turn off but it Does not turn back on ..

#include <LiquidCrystal_I2C.h>
#include "DHT.h"

LiquidCrystal_I2C lcd(0x27, 16, 2);

// ********************* . LCD Pin and State ********************* //
int LCDState = 0;
int LCDPin = A4;

// ********************* . BUTTON Pin and State ********************* //
int buttonPin = A0;
int buttonNew ;
int buttonOld = 0;

// Define Relay(s)
#define relayTemp 4
#define relayHum 7

#define DHTPIN 2 // Digital pin connected to the DHT sensor
// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11 // DHT 11
#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 to 3.3V instead of 5V, HellO!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors. This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

float maxTemperature = 84.00; // The Max Temperature allowed
float minTemperature = 78.00; // The Min Temperature allowed
float maxHumidity = 90; // The Max Temperature allowed
float minHumidity = 80; // The Min Temperature allowed

void setup() {
// Setup the number of columns and rows that are available on the LCD.
Serial.begin(9600);
lcd.begin();

pinMode(LCDPin, OUTPUT);
pinMode(buttonPin, INPUT);

Serial.println(F("Shroom-Full-Kit!"));
lcd.print("Happy Shrooms...");
lcd.setCursor(3, 1);
lcd.print(" Shroooms!");
delay(3000);

dht.begin();

pinMode(relayTemp, OUTPUT); // Sets Relay
pinMode(relayHum, OUTPUT);
}

void loop() {
buttonNew = digitalRead(buttonPin);
if (buttonNew==1 && buttonOld == 0){
if (LCDState==1){
digitalWrite(LCDPin, HIGH);
lcd.backlight(); // turn on backlight.
Serial.println("LCD is ON");
delay(5);
}
else{
digitalWrite(LCDPin, LOW);
lcd.noBacklight(); // turn off backlight.
Serial.println("LCD is OFF");
delay(5);
}
}
buttonOld=buttonNew;
delay(200);

// scroll 13 positions (string length) to the left
// to move it offscreen left:
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}

// scroll 29 positions (string length + display length) to the right
// to move it offscreen right:
for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
// scroll one position right:
lcd.scrollDisplayRight();
// wait a bit:
delay(150);
}

// scroll 16 positions (display length + string length) to the left
// to move it back to center:
for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}

// delay at the end of the full loop:
delay(1000);

// clear screen loop:
lcd.clear();

// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);

// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}

// Compute heat index in Fahrenheit (the default)
float hif = dht.computeHeatIndex(f, h);
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print(F("Humidity: "));
Serial.print(h);

Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);

Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(F("°F"));

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Temp.: "); // Prints string "Temp." on the LCD
lcd.print(f); // Prints the temperature value from the sensor
lcd.print(" F");
lcd.setCursor(0,1);
lcd.print("Humi.: ");
lcd.print(h);
lcd.print(" %");
delay(3500);
lcd.clear();

if (f >= minTemperature) {
digitalWrite(relayTemp, HIGH);
Serial.println("Temp OFF: ");
lcd.setCursor(3,0);
lcd.print("HEAT is OFF: ");
} else if (f <= minTemperature) {
digitalWrite(relayTemp, LOW);
Serial.println("Temp ON: ");
lcd.setCursor(3,0);
lcd.print("HEAT is ON: ");

}

if (h >= minHumidity) {
digitalWrite(relayHum, HIGH);
Serial.println("Fogger OFF: ");
lcd.setCursor(3,1);
lcd.print("FOGGER is OFF: ");
} else if (h <= minHumidity) {
digitalWrite(relayHum, LOW);
Serial.println("Fogger ON: ");
lcd.setCursor(3,1);
lcd.print("FOGGER is ON: ");
delay(1000);
}
}

Can you do us the courtesy and please read the forum tips on HOW to post code !

[code
]ah ... i got it now .. wont happen again .. sry yall .. and dont yell at the new kid... but ty .. ill be sure to compute properly within the forum ..

A good try, but you missed the code itself !

NOT YELLING. JUST POINTING YOU IN THE RIGHT DIRECTION TO GET THE BEST HELP

i`m learning but, i got it .. and i have a wait period .. ty you again

i need some help with this Code... i can get the LCD to turn OFF but not ON ..

#include <LiquidCrystal_I2C.h>
#include "DHT.h"

LiquidCrystal_I2C lcd(0x27, 16, 2);

//   ********************* .  LCD Pin and State   *********************   //
int LCDState = 0;
int LCDPin = A4;

//   ********************* .  BUTTON Pin and State   *********************   //
int buttonPin = A0;
int buttonNew ;
int buttonOld = 0;

// Define Relay(s)
#define relayTemp 4
#define relayHum 7

#define DHTPIN 2     // Digital pin connected to the DHT sensor
// Pin 15 can work but DHT must be disconnected during program upload.

// Uncomment whatever type you're using!
//#define DHTTYPE DHT11   // DHT 11
#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
//#define DHTTYPE DHT21   // DHT 21 (AM2301)

// Connect pin 1 (on the left) of the sensor to +5V
// NOTE: If using a board with 3.3V logic like an Arduino Due connect pin 1 to 3.3V instead of 5V, HellO!
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

// Initialize DHT sensor.
// Note that older versions of this library took an optional third parameter to
// tweak the timings for faster processors.  This parameter is no longer needed
// as the current DHT reading algorithm adjusts itself to work on faster procs.
DHT dht(DHTPIN, DHTTYPE);

float maxTemperature = 84.00; // The Max Temperature allowed
float minTemperature = 78.00; // The Min Temperature allowed
float maxHumidity = 90; // The Max Temperature allowed
float minHumidity = 80; // The Min Temperature allowed

void setup() {
  // Setup the number of columns and rows that are available on the LCD.
  Serial.begin(9600);
  lcd.begin();
 
  pinMode(LCDPin, OUTPUT);
  pinMode(buttonPin, INPUT);

  Serial.println(F("Shroom-Full-Kit!"));
  lcd.print("Happy Shrooms...");
  lcd.setCursor(3, 1);
  lcd.print(" Shroooms!");
  delay(3000);

  dht.begin();

  pinMode(relayTemp, OUTPUT);  // Sets Relay
  pinMode(relayHum, OUTPUT);
}
 
void loop() {
  buttonNew = digitalRead(buttonPin);
  if (buttonNew==1 && buttonOld == 0){
    if (LCDState==1){
      digitalWrite(LCDPin, HIGH);
      lcd.backlight(); // turn on backlight.
      Serial.println("LCD is ON");
      delay(5);
   }
   else{
    digitalWrite(LCDPin, LOW);
    lcd.noBacklight(); // turn off backlight.
    Serial.println("LCD is OFF");
    delay(5);
    }
}
 buttonOld=buttonNew;
 delay(200);

   // scroll 13 positions (string length) to the left
  // to move it offscreen left:
  for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft();
    // wait a bit:
    delay(150);
  }

  // scroll 29 positions (string length + display length) to the right
  // to move it offscreen right:
  for (int positionCounter = 0; positionCounter < 29; positionCounter++) {
    // scroll one position right:
    lcd.scrollDisplayRight();
    // wait a bit:
    delay(150);
  }
 
    // scroll 16 positions (display length + string length) to the left
    // to move it back to center:
  for (int positionCounter = 0; positionCounter < 16; positionCounter++) {
    // scroll one position left:
    lcd.scrollDisplayLeft();
    // wait a bit:
    delay(150);
  }
 
  // delay at the end of the full loop:
  delay(1000);
 
  // clear screen loop:
  lcd.clear();

  // Reading temperature or humidity takes about 250 milliseconds!
  // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
  float h = dht.readHumidity();
  // Read temperature as Celsius (the default)
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit (isFahrenheit = true)
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println(F("Failed to read from DHT sensor!"));
    return;
  }

  // Compute heat index in Fahrenheit (the default)
  float hif = dht.computeHeatIndex(f, h);
  // Compute heat index in Celsius (isFahreheit = false)
  float hic = dht.computeHeatIndex(t, h, false);
  Serial.print(F("Humidity: "));
  Serial.print(h);
 
  Serial.print(F("%  Temperature: "));
  Serial.print(t);
  Serial.print(F("°C "));
  Serial.print(f);
 
  Serial.print(F("°F  Heat index: "));
  Serial.print(hic);
  Serial.print(F("°C "));
  Serial.print(hif);
  Serial.println(F("°F"));

  lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
  lcd.print("Temp.: "); // Prints string "Temp." on the LCD
  lcd.print(f); // Prints the temperature value from the sensor
  lcd.print(" F");
  lcd.setCursor(0,1);
  lcd.print("Humi.: ");
  lcd.print(h);
  lcd.print(" %");
  delay(3500);
  lcd.clear();

  if (f >= minTemperature) {
    digitalWrite(relayTemp, HIGH);
    Serial.println("Temp OFF: ");
    lcd.setCursor(3,0);
    lcd.print("HEAT is OFF: ");
  } else if (f <= minTemperature) {
    digitalWrite(relayTemp, LOW);
    Serial.println("Temp ON: ");
    lcd.setCursor(3,0);
    lcd.print("HEAT is ON: ");
     
  }

   if (h >= minHumidity) {
    digitalWrite(relayHum, HIGH);
    Serial.println("Fogger OFF: ");
    lcd.setCursor(3,1);
    lcd.print("FOGGER is OFF: ");
  } else if (h <= minHumidity) {
    digitalWrite(relayHum, LOW);
    Serial.println("Fogger ON: ");
    lcd.setCursor(3,1);
    lcd.print("FOGGER is ON: ");
    delay(1000);
  }
}

LCDState is initialised as 0 then never changed.

Steve