Button input on one line not working

Got a LCD shield with 5 buttons on it all buttons go onto one wire each one has a different value resister so that the current of the wire can be checked and know with button was pressed

I've noted down the values that you get when each button is pressed and used if loops to print out which button was pressed but for some reason if prints 337 when the serial.println() is at he end of the void loop and prints 298 when the serial.println() is at the beginning of the void loop

// include the library code:
#include <LiquidCrystal.h>

// with the arduino pin number it is connected to
int Value = 0;
int button = "";
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("hello ");
  Serial.begin(9600);
}

void loop() {
  //sets value as the value from A3
  Serial.println(button);
  Value = analogRead(A3);
    if (88 < Value < 96){
      button = "BACK";
      }
    else if (311 < Value < 325){
      button = "MENUE";
      }
    else if (174 < Value < 182){
      button = "DOWN";
      }
    else if (684 < Value < 691){
      button = "UP";
      }
    else{
      button = " ";
    }
    Serial.println(button);
    Serial.println(Value );
    delay(1000);
}

this prints
298
298
1019

Doesn't work like you think it does.
Use two comparisons and a logical AND

Welcome to the forum

if (88 < Value < 96)

This syntax is wrong

I think that you meant

if (Value > 88 && Value < 96)

Please copy and paste the actual output, don't just paraphrase it.

No, the semantics are wrong.
If the syntax were wrong, the compiler would have complained

C/C++ sees this as

    if ( (88 < Value) < 96){

if (88 < Value < 96) is wrong why does it print 298 for the Serial.println(button); since button is empty
and this is the full out put
298

298

1019

298

298

1019

298

1019 being Value and 298 bieng button

changed it to if (Value > 684 && Value < 691) but still didnt work

What were you thinking?

keep button as an empty string and then set the value in the if loop

And how are you storing that "string"?
(There's a hint in my last post)

I dont get what you mean

See reply 10

oh was storing it as an int not string new to c++ so didn't know you hade to declare the type of string

There is no string type - it's String.

meant variable type

See reply 16

what would I put instead of int , char??

Hello setonic

Try and consider these small mods to your sketch.

// include the library code:
#include <LiquidCrystal.h>

// with the arduino pin number it is connected to
int Value = 0;
int button = "";
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);
  // Print a message to the LCD.
  lcd.print("hello ");
  Serial.begin(9600);
}

void loop() {
  //sets value as the value from A3
  Serial.print(button);
  Value = analogRead(A3);
  Serial.print(F(" "));
  Serial.println(Value);

  switch (Value)
  {
    case 88 ... 96:
      Serial.println(F("BACK"));
      break;
    case 311 ... 325:
      Serial.println(F("MENUE"));
      break;
    case 174 ... 182:
      Serial.println(F("DOWN"));
      break;
    case 684 ... 691:
      Serial.println(F("UP"));
      break;
      default: 
      Serial.println(F("-----"));
      break;
  }
/*

}
if (88 < Value < 96) {
  button = "BACK";
}
else if (311 < Value < 325) {
  button = "MENUE";
}
else if (174 < Value < 182) {
  button = "DOWN";
}
else if (684 < Value < 691) {
  button = "UP";
}
else {
  button = " ";
}
Serial.println(button);
Serial.println(Value );
*/
delay(1000);
}

Have a nice day and enjoy coding in C++.