LCD Shield Buttons Not Working

I have a 1602 V2 shield with a keypad. Here is the link to the exact one I have https://www.sparkfun.com/products/13293.

In my code I used the schematic’s resistor numbers but it’s not working. https://cdn.sparkfun.com/datasheets/Dev/Arduino/Shields/16X2_LCD_shield.pdf.

This is what have have for code. I’m very new to coding so there may be a mistake I made too.

// Setup lcd object with display pinouts
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

// Define button constants
#define btnRIGHT 0
#define btnUP 1
#define btnDOWN 2
#define btnLEFT 3
#define btnSELECT 4
#define btnNONE 5

// Define variable to hold current button constant value
int lcd_key = 0;

// Define variable to hold button analog value
int adc_key_in = 0;

// Function to read the buttons
// Returns button constant value
int read_LCD_buttons()
{
// read the value from the sensor
adc_key_in = analogRead(0);

if (adc_key_in > 10) return btnNONE; // No button is pressed
if (adc_key_in < 39) return btnRIGHT; // Right pressed
if (adc_key_in < 100) return btnUP; // Up presed
if (adc_key_in < 75) return btnDOWN; // Down pressed
if (adc_key_in < 51) return btnLEFT; // Left pressed
if (adc_key_in < 15) return btnSELECT; // Select pressed
return btnNONE; // If no valid response return No button pressed
}

void setup()
{
// Setup the LCD display
lcd.begin(16, 2);
// Set cursor to top line first position
lcd.setCursor(0,0);
// Print message on first line
lcd.print(“G-O-Metric”);
}

void loop()
{
// Move cursor to second line, 9 spaces over
lcd.setCursor(9,1);
// Display seconds elapsed since reset
lcd.print(millis()/1000);

// Move to the begining of the second line
lcd.setCursor(0,1);

// Call the read buttons function
lcd_key = read_LCD_buttons();

// Print button value on second line
switch (lcd_key)
{
case btnRIGHT:
{
lcd.print(“RIGHT”);
break;
}
case btnLEFT:
{
lcd.print(“LEFT”);
break;
}
case btnUP:
{
lcd.print(“UP”);
break;
}
case btnDOWN:
{
lcd.print(“DOWN”);
break;
}
case btnSELECT:
{
lcd.print(“SELECT”);
break;
}
case btnNONE:
{
lcd.print(“NONE”);
break;
}
}

}

At least this is certainly wrong:

. . .
   adc_key_in = analogRead(0);
       

   if (adc_key_in > 10) return btnNONE; // No button is pressed
   if (adc_key_in < 39)   return btnRIGHT; // Right pressed
   if (adc_key_in < 100)  return btnUP;  // Up presed
   if (adc_key_in < 75)  return btnDOWN;  // Down pressed
   if (adc_key_in < 51)  return btnLEFT;  // Left pressed
   if (adc_key_in < 15)  return btnSELECT; // Select pressed
   return btnNONE;  // If no valid response return No button pressed
} 
. . .

I guess the first statement must be wrong because it prevents any of the other statements being executed except if adc_key_in has the value 10 or less, in which case only the last statement could be executed.

Right, first things first.

Please go and read the instructions, then go back and modify your post (use the "More --> Modify" option to the bottom right of the post) to mark up the code (but it needs to be the complete code) as such so we can examine it conveniently and accurately. Do not post a ".ino" file as an attachment - that would mean that you are expecting people to actually load it to their IDE to look at it and that is extra unnecessary labour. In fact, attachments do not always show properly on different operating systems.

If you do not mark it up as code, the code you post could well be garbled and is certainly anything but easy to read.

Note: Also mark up any data in the same way. This includes error output that you get from the IDE.

And - before you post any code, use "Auto Format" in the Tools menu of the IDE to properly present the code.

Try and avoid unnecessary white space (blank lines). You should only use these to separate functional blocks of code.

Until you reply and demonstrate that you understand these points that have been made so far, there may be little point working through the other problems with the code, and I suspect other people feel the same way, so I will leave it at that for the present.