automatic irrigation system

Good evening, I hope that everyone who reads this post is well, my question was about how to make pressing a button switch me between two different data
#include <LiquidCrystal.h>
LiquidCrystal lcd(2,3,4,5,6,7);

#define VELOCIDAD 300
#define ARRAYTXT 5

float Humedad;
float Clorofila;
int indice;
int val = 0;
int old_val = 0;
int state = 0;
const int BOTON=8;

void setup() {
lcd.begin(16,2);
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
pinMode(8,INPUT);
}

void loop() {

val= digitalRead(BOTON);

if ((val == HIGH) && (old_val == LOW)){
state=1-state;
val++;
delay(10);
}

old_val = val;

if(state==1) {

String textos[ARRAYTXT] = {“Fuera del suelo”,“Suelo Seco”,“Suelo Humedo”,“Mucha Humedad”};

Humedad = analogRead(A0);
int percentage = map(Humedad, 0,1023, 100, 0);
Serial.println(Humedad);
lcd.clear();
lcd.print(“Humedad del: “);
lcd.print(percentage);
lcd.println(”%”);

if(Humedad >= 1000) {
indice = 0;
}
else if (Humedad <1000 && Humedad >= 600) {
indice = 1;
}
else if (Humedad < 600 && Humedad >= 370){
indice = 2;
}
else if (Humedad < 370) {
indice = 3;
}

lcd.setCursor(0,1);
lcd.print(textos[indice]);

}

if(state==2) {

String textos[ARRAYTXT] = {“Solo Luz Solar”,“Baja Clorofila”,“Alta Clorofila”,“Ambiente Oscuro”};

Clorofila = analogRead(A1);
Serial.println(Clorofila);
lcd.clear();
lcd.print(“Nivel Clorofila:”);

if(Clorofila >= 900) {
indice = 0;
}
else if(Clorofila < 900 && Clorofila >= 800){
indice = 1;
}
else if(Clorofila >= 700 && Clorofila <= 799){
indice = 2;
}
else if(Clorofila < 700){
indice = 3;
}
lcd.setCursor(0,1);
lcd.print(textos[indice]);

}

}

This is the code that I have so far, my idea is to try to press the button to alternate between “Humedad” and " Clorofila"
thanks for your attention

You need to say what the code actually does at the moment, and explain in what what that differs from what it's supposed to do.

Please read the first topics like "How to use this Forum", edpecislly how to preoare and post code.

void loop() 
{     
    val = digitalRead(BOTON);
    if( val != old_val )
    {
        old_val = val;
        if( val == LOW )
        {
            if( state == 1 )
                state = 2;
            else
                state = 1;
                
        }//if
                 
    }//if
      
    if(state==1) 
    {      
        String textos[ARRAYTXT] = {"Fuera del suelo","Suelo Seco","Suelo Humedo","Mucha Humedad"};
.
.
.

I already tried to change the code but the only thing I managed was to make the screen show me the result of humidity sensor when I press the button, I can`t see the result of the other sensor.

  #include <LiquidCrystal.h>
  LiquidCrystal lcd(2,3,4,5,6,7);

#define VELOCIDAD 300 
#define ARRAYTXT 5

float Humedad; 
float Clorofila;
int indice; 
int val = 0;
int old_val = 0;
int state = 0;
const int BOTON=8;
  


 
void setup() {
  lcd.begin(16,2);
  Serial.begin(9600);
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  pinMode(8,INPUT);
}

void loop() { 

val= digitalRead(BOTON);
  
if (val != old_val){
  old_val = val;

  if(val == LOW){
  
    if(state==1) {
      
      String textos[ARRAYTXT] = {"Fuera del suelo","Suelo Seco","Suelo Humedo","Mucha Humedad"};

        Humedad = analogRead(A0);
          int percentage = map(Humedad, 0,1023, 100, 0); 
          Serial.println(Humedad);
          lcd.clear();
          lcd.print("Humedad del: ");
          lcd.print(percentage);
          lcd.println("%");
  
        if(Humedad >= 1000) {
          indice = 0;
  }
          else if (Humedad <1000 && Humedad >= 600) {
            indice = 1;
  }
            else if (Humedad < 600 && Humedad >= 370){
              indice = 2;
  }
              else if (Humedad < 370) {
                indice = 3;
  }
  
        lcd.setCursor(0,1);
        lcd.print(textos[indice]);
        
  
      
    }



    if(state==2) {
                
  String textos[ARRAYTXT] = {"Solo Luz Solar","Baja Clorofila","Alta Clorofila","Ambiente Oscuro"};
      
      Clorofila = analogRead(A1);
      Serial.println(Clorofila);  
      lcd.clear();
      lcd.print("Nivel Clorofila:"); 

     if(Clorofila >= 900) {
       indice = 0;
     }
      else if(Clorofila < 900 && Clorofila >= 800){
        indice = 1;
    }
        else if(Clorofila >= 700 && Clorofila <= 799){
             indice = 2;
        }
          else if(Clorofila < 700){
              indice = 3;
          }
    lcd.setCursor(0,1);
    lcd.print(textos[indice]);

       
    }        

  
}

The function of the code that I wrote is to read the results of several sensors and put them on a 16x2 lcd screen, I try to put the results of each sensor separately, so when I press the button, the lcd will show the one of the “Humedad”, that of “Clorofila”, etc. As well as a kind of menu.

but what happens when I press the button is that it only returns the result of a single sensor, as well as delay but in button.

I still need to put the relay and the water pump so that I can start with the cultivation, but first I want to have that part ready.

The problem is your state variable. In your latest version it never changes. In the original it looks like a button press flips it between 0 and 1.

sorry for my ignorance but could you explain a little more please, I'm new in arduino

If you're struggling, then I think you have too much code. Try to do something simpler. Currently, you depend on the value of state to choose which sensor to read and display on the LCD. You have no code to change state now, so your code does nothing.

Forget the LCD, forget the sensors. Just read the button and adjust the state variable and print it to serial. When that's working, add a tiny bit more code. Rinse and repeat.