Hy DanBeno! Have you tried the following configurations?
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5
int read_LCD_buttons()
{
x = analogRead(0); // read the value from the sensor
delay(5); //switch debounce delay. Increase this delay if incorrect switch selections are returned.
int k = (analogRead(0) - x); //gives the button a slight range to allow for a little contact resistance noise
if (5 < abs(k)) return btnNONE; // double checks the keypress. If the two readings are not equal +/-k value after debounce delay, it tries again.
// my buttons when read are centered at these values: 0, 144, 329, 504, 741
// we add approx 50 to those values and check to see if we are close
if (x > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result
if (x < 50) return btnRIGHT;
if (x < 195) return btnUP;
if (x < 380) return btnDOWN;
if (x < 555) return btnLEFT;
if (x < 790) return btnSELECT;
return btnNONE; // when all others fail, return this…
}
lcd_key = read_LCD_buttons();
checkBtns = false;
switch(lcd_key){
case btnRIGHT:
Serial.println("btnRight");
break;
case btnLEFT:
Serial.println("btnLeft");
break;
case btnUP:
Serial.println("btnUp");
increment = 1;
break;
case btnDOWN:
Serial.println("btnDown");
increment = -1;
break;
case btnSELECT:
Serial.println("btnSelect");
data_item++;
break;
default:
break;
}