One Button Humidity Controller

Currently I am coding a hs22 with one lcd, one button, and one relay attached

I would like to be able to select between 3 operating modes

Basiclly

75% 85% 95% RH

so far here is my code

#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include "DHT.h"
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define RELAY 3
#define DHTPIN 12
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const int buttonPin = 2;
int buttonState = 0;
int tgtRH = 85;

void setup() {
pinMode(RELAY,OUTPUT);
pinMode(buttonPin, INPUT);
digitalWrite(RELAY,HIGH);
Serial.begin(9600);

lcd.begin(16, 2);
dht.begin();
}

void loop() {

//DHT Code
buttonState = digitalRead(buttonPin);
// Wait a few seconds between measurements.
delay(2000);

// 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
float t = dht.readTemperature();
// Read temperature as Fahrenheit
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("Failed to read from DHT sensor!");
return;
}

// Compute heat index
// Must send in temp in Fahrenheit!
float hi = dht.computeHeatIndex(f, h);

Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(hi);
Serial.println(" *F");
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f);
lcd.print(" H ");
lcd.print(h);
//DHT Code Ends
lcd.setCursor(0, 1);
//ButtonCode Starts

//Relay Code Ends

lcd.print(millis()/1000);
}

I need some help coding in the button if statements please

if button pressed and 75% RH then switch to 85, if button pressed again & 85 then 95, if 95 then 75

and then have the relay activate if the value (h) is 5% below target and shut off when it reaches the target

You spend a lot of time in the main loop doing other things instead of listening for the button press.

I would try structuring your code like this pseudcode.
Remove the delay and learn how to change things based on millis().
See the blink without delay example in the IDE or here.

void loop() {
buttonState = digitalRead(buttonPin);

if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;   

 getSensorData();
 otherCalculations()

  }
}

void getSensorData(){

// do sensor stuff here

}

void otherCalculations(){

// do other stuff here

}

#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include "DHT.h"
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define RELAY 3
#define DHTPIN 12
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
#define BUTTON 4
int buttonState = 0;
int tgt = 75;
boolean value = false;

void setup() {
pinMode(RELAY,OUTPUT);
pinMode(BUTTON,INPUT);
digitalWrite(RELAY,HIGH);
Serial.begin(9600);

lcd.begin(16, 2);
dht.begin();
}

void loop() {

//DHT Code

// Wait a few seconds between measurements.
delay(2000);

// 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
float t = dht.readTemperature();
// Read temperature as Fahrenheit
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("Failed to read from DHT sensor!");
return;
}

float hi = dht.computeHeatIndex(f, h);
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f);
lcd.print(" H ");
lcd.print(h);
//DHT Code Ends
lcd.setCursor(0, 1);

lcd.print(tgt);

//Button Code

if (digitalRead(BUTTON) == LOW && tgt == 75)
{tgt = 85;}
if (digitalRead(BUTTON) == LOW && tgt == 85)
{tgt = 95;}
if (digitalRead(BUTTON) == LOW && tgt == 95)
{tgt = 75;}
}

at this point i can only get it to switch from 75 to 85 and then nothing else

Please put your code in code tags so it is easier to read. </>
In your latest code you still have the delay.
So for 2 whole seconds your program stops and does nothing, not even listen for button presses.

You may also need to debounce the button http://www.arduino.cc/en/Tutorial/Debounce

#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include "DHT.h"
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define RELAY 3
#define DHTPIN 12
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
const int buttonPin = 5;
int buttonPinState = 0;
int tgt = 75;
boolean value = false;

void setup() {
pinMode(RELAY,OUTPUT);
pinMode(buttonPin,INPUT);
digitalWrite(RELAY,HIGH);
Serial.begin(9600);

lcd.begin(16, 2);
dht.begin();
}

void loop() {

//DHT Code

// 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
float t = dht.readTemperature();
// Read temperature as Fahrenheit
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("Failed to read from DHT sensor!");
return;
}

float hi = dht.computeHeatIndex(f, h);
lcd.setCursor(0, 0);
lcd.print("T ");
lcd.print(f);
lcd.print(" H ");
lcd.print(h);
//DHT Code Ends
lcd.setCursor(0, 1);

lcd.print(tgt);

//buttonPin Code

int reading = digitalRead(buttonPin);

if (digitalRead(buttonPin) == LOW && tgt == 75)
{tgt = 85;}
if (digitalRead(buttonPin) == LOW && tgt == 85)
{tgt = 95;}
if (digitalRead(buttonPin) == LOW && tgt == 95)
{tgt = 75;}
}

I'm unsure how to use a code tag </>?

#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include "DHT.h"
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
#define RELAY 3
#define DHTPIN 12
#define DHTTYPE DHT22 
DHT dht(DHTPIN, DHTTYPE);
const int buttonPin = 5;
int buttonPinState = 0;
int tgt = 70;
int counter = 0;
boolean value = false; 

void setup() {
   pinMode(RELAY,OUTPUT);
   pinMode(buttonPin,INPUT);
   digitalWrite(RELAY,HIGH);
  Serial.begin(9600);
  
  lcd.begin(16, 2);
  dht.begin();
}

void loop() {
  
  //DHT Code

  // 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
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  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("Failed to read from DHT sensor!");
    return;
  }


  float hi = dht.computeHeatIndex(f, h);
  lcd.setCursor(0, 0);
  lcd.print("T ");
  lcd.print(f);
  lcd.print(" H ");
  lcd.print(h);
  //DHT Code Ends
  lcd.setCursor(0, 1);
  
  lcd.print(tgt);
  
  //buttonPin Code
 
 int reading = digitalRead(buttonPin);
  
  
if (h <= tgt)
   digitalWrite(RELAY,LOW);
else
digitalWrite(RELAY,HIGH);
  
  
  switch (tgt) {
    
case 70:
      if (digitalRead(buttonPin) == HIGH) {tgt = 75;}
      break;   
case 75:
      if (digitalRead(buttonPin) == HIGH) {tgt = 80;}      
      break;
case 80:
      if (digitalRead(buttonPin) == HIGH) {tgt = 85;}
      break;
case 85:
      if (digitalRead(buttonPin) == HIGH) {tgt = 90;}
      break;
case 90:
      if (digitalRead(buttonPin) == HIGH) {tgt = 95;}   
      break;
case 95:
      if (digitalRead(buttonPin) == HIGH) {tgt = 70;} 
      break;   
  
 }
}

I ended up solving my own problem here's the code for anyone who might have the same issue

Make an array of your humidity values and use the button to increase an index variable.

  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);

Why do you need to do both?

Why not?

It's just wasting RAM. You can calculate one with the other.

Wouldn't doing the conversion also be wasting resources. In fact all of the unusedlines of code could be considered wasting. I'd prefer to leave it in as I can only speculate what uses that bit of code might fulfill for the next guy