LCD showing unreadable characters

I’m new at Arduino using. I can display analog values in LCD or control servo angle depending on analog value alone. But when i tried to do all three of them…take analog values from LDR, control servo angle depending on the analog value & display the angle in LCD, I found some unreadable characters displaying on the LCD. Can somebody please help me to figure out the error in my code…

#include <Servo.h>
#include <LiquidCrystal.h>

Servo myservo;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int potpin = 0;
int val;

void setup()
{
myservo.attach(9);
lcd.begin(16, 2);
lcd.print(" SERVO ANGLE");
delay(1500);
}

void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 179);
myservo.write(val);
lcd.clear();
delay(20);
lcd.print(val);

}

Using lcd.clear() in loop() is not a good idea because of the time involved to do the clear operation. This could be at least part of your problem.

Your best choice is to just reposition the cursor and overwrite the old values with the new.

Don