#include <LiquidCrystal_I2C.h> 
LiquidCrystal_I2C lcd(0x27,16,2);
int aVal=0,tempx=0,x;
void setup()
{
  lcd.begin();
}
void loop() 
{
aVal = analogRead(A0);
lcd.setCursor(0,0);
x = map(aVal,0,1023,1,17);
  if (tempx != x)
  {
    lcd.clear();
    for(int i=0;i<x;i++)
    {
      lcd.print("*");
    }
  }
  tempx = x;
}

