I2c lcd only showing upper blocks nothing else

I m making a distance measurement using arduino , ultrasonic sensor and i2c lcd.
But after installing code also nothing visible on my screen only upper blocks is visible.
THIS IS MY CODE

#include <Wire.h> // Library for I2C communication
#include <LiquidCrystal_I2C.h> // Library for LCD
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2); // Change to (0x27,16,2) for 16x2 LCD.my address is (0x3F)

int trigPin = A0;
int echoPin = A1;

long distance;
long distanceInch;
long duration;

void setup(){
 lcd.begin();
 lcd.backlight();
 pinMode(trigPin, OUTPUT);
 pinMode(echoPin, INPUT);

 lcd.setCursor(0,0);
 lcd.print("   WELCOME TO");
 lcd.setCursor(0,1);
 lcd.print("  MKINVENTIONS");
 delay(2000);
}

void loop() {
 ULTRASONIC();
 lcd.clear();
 lcd.setCursor(0,0);
 lcd.print("DISTANCE CM:");
 lcd.print(distance); 
 lcd.setCursor(0,1);
 lcd.print("DISTANCE INCH:");
 lcd.print(distanceInch); 

// lcd.setCursor(0,1);   
// lcd.print("DISTANCE MM:");
// lcd.print(distanceInch); 
}

void ULTRASONIC(){
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = duration*0.034/2;
  distanceInch = duration*0.0133/2;
} 

Turn the LCD contrast potentiometer down to the point where the blocks just appear.

I did that also then also its nt working only upper blocks r there .
Even though I have tried a simple hello world cold also but that's also not showing

What address is your I2C LCD ?

0*27

please help regarding this issue

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to [url=https://forum.arduino.cc/index.php?topic=710766.0]Learn How To Use The Forum[/url].

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Have you tried the LCD example(s) that came with the LCD library? Did they work?

OK, not sure why Larry is barking up the wrong tree (and Mark just noted, sadly has no idea!).

You are seeing the "blocks" on the first line. That means your contrast control is set more-or-less correctly - good enough in any case.

What the "blocks" mean is that you are not "talking" to the display. Why? Well, using a completely obsolete library, sad to say! :worried:

OK, use the Library Manager in the IDE to install Bill Perry's "HD44780" library and then run from that library, the examples > ioClass > hd44780_I2Cexp > I2CexpDiag sketch to find the details for and test your display.

You can then work from one of the sketches in that directory to build what you need to. :grin:

I wouldn't DREAM of using the HD44780 library. I have tried that one, but it just ISN'T as good OR easy to use as the one @rajaarin is currently using.
@rajaarin, your screen will NEVER display anything with

lcd.begin();

You MUST use

lcd.init();

Change that and it should work.

Whether you use lcd.init() or lcd.begin() depends entirely on which library you are using

As usual, the Devil is in the detail

@UKHeliBob
True.
The library in rajaarin's code uses lcd.begin(); though, not init();.

I must have missed where we established exactly which library was being used

If that was intended to show exactly which library is being used then it was a failure. All it shows is that the library is named LiquidCrystal_I2C, of which there are several

Yeah, I guess. I just assumed it was the most used one.