Simple Text input using 5 buttons
Several issues in the code you posted:


Every change to the text you do inside the for loop, will not be reflected to the LCD until the for loop will end (when i&lt;limit will no longer be a true statement). You might want to add an additional code, inside the for loop and outside any of its conditional statements, that will repeatedly set the cursor and print input to the LCD. Something similar to the code you have prior to the for loop:

void intext() 
{
  ... // rest of the code until the for loop

  for (int i; i&lt;limit; ) 
  {
    ... // all the conditions for up/down/left/right/ok

    lcd.setCursor(0,1);
    lcd.print(input);
  }
}

Another problem is that when the user clicks left, the counter should be decremented, not incremented, and you should check for left boundary:

if(digitalRead(le)==HIGH &amp;&amp; i&gt;0) // left boundary check added
{
   delay(1000); 
   i=i-1; // and not i=i+1;

}

After clicking Ok, and since the for loop does not increment i, the condition in the for loop (i&lt;limit) will stay true, and the loop will not end until the user will click Right once more. To mitigate this, change the following

if(digitalRead(ok)==HIGH)
{
  lim=i; // and not: lim=i+1;
  delay(1000); 
}



Otherwise, the user will have to click Right for completion, to increment i once more. 


jfpoilpret comment about pull up/down is very important. Make sure you use pull up/pull down resistors in order to prevent input debounce (more details inside this link).