Problems implenting code on 20x4 LCD but code works on 16x2

floresta:
One thing you should try to avoid is the use of lcd.clear() in a loop.[/color]

Right it will clear the LCD every time the main loop is run, something that isn't necessary unless the output has changed. This can be avoided with a flag value and some conditional logic like the following:

 if (clearLCDFlag == true) lcd.clear();