LCD Input and Output

  1. Arduino_LCD_KeyPad_Shield__SKU__DFR0009_-DFRobot

String inputCoordinates() {
  lcd.begin(16, 2);              // set LCD to top row
  if(iteration = 1) {
  lcd.print("Input Latitude"); // print instructions to operator
  }
  else {
  lcd.print("Input Longitude"); // print instructions to operator
  }
  int space = 0;
  int digit[] = {0,0,0,0,0,0,0,0,0};
  int run = 1;
  lcd.setCursor(0,1);
  lcd.print("0000.0000");
  delay(200);
  while(run = 1) {
    while(Serial.available() > 0) {    
      lcd.write(Serial.read());  // read the buttons
    }
    switch (lcd_key)  {    // depending on which button was pushed, we perform an action   
      case btnRIGHT: {     
        space++;
        if (space == 4) {
          space++;
        }
      }
      case btnLEFT: {     
        space--;
        if (space == 4) {
          space--;
        }     
      }
      case btnUP: {
        digit[space] = digit[space] + 1;
        lcd.setCursor(space,1);
        lcd.print(digit[space]);
      }
      case btnDOWN: {
        digit[space] = digit[space] - 1;
        lcd.setCursor(space,1);
        lcd.print(digit[space]);
      }   
      case btnSELECT: {     
        run = 0;
      }
      case btnNONE:{
      }
    }
    String digit0 = "";
    digit0 += digit[0];
    String digit1 = "";
    digit1 += digit[1];
    String digit2 = "";
    digit2 += digit[2];
    String digit3 = "";
    digit3 += digit[3];
    String digit5 = "";
    digit5 += digit[5];
    String digit6 = "";
    digit6 += digit[6];
    String digit7 = "";
    digit7 += digit[7];
    String digit8 = "";
    digit8 += digit[8];
    String coordinate = "";
    coordinate += digit0 + digit1 + digit2 + digit3 + digit5 + digit6 + digit7 + digit8;
    return coordinate;
 }
}

int read_LCD_buttons(){ 
adc_key_in = analogRead(0);      // read the value from the sensor  
 // my buttons when read are centered at these valies: 0, 144, 329, 504, 741 
 // we add approx 50 to those values and check to see if we are close 
 if (adc_key_in > 1000) return btnNONE; // We make this the 1st option for speed reasons since it will be the most likely result 
 if (adc_key_in < 50)   return btnRIGHT;   
 if (adc_key_in < 195)  return btnUP;  
 if (adc_key_in < 380)  return btnDOWN;  
 if (adc_key_in < 555)  return btnLEFT;  
 if (adc_key_in < 790)  return btnSELECT;    
 return btnNONE;  // when all others fail, return this...
}
  1. Delays don't work. Even if I made a long enough delay, I am trying to get it so that the user hits a button (the select button) and the data is passed into the code. There are a series of 0's displayed across the LCD. The user is supposed to move the cursors (left or right) and then change the digit values using (higher or lower). Once the user is satisfied with the numbers displayed, the user hits the select button to then input another value.

I have tried placing a while loop that would only be satisfied until that select button was hit. However, this did not solve the problem, as all the LCD continued to not show any input changes.