//www.elegoo.com //2016.12.08 #include "SR04.h" #include #include LiquidCrystal_I2C lcd(0x27, 16, 2); //stating the address and size of the lcd #define TRIG_PIN 9 #define ECHO_PIN 10 SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN); long a; void setup() { lcd.init(); //Initializing the lcd lcd.backlight(); //starting the backlight of the lcd } void loop() { a=sr04.Distance(); lcd.clear(); lcd.print("Distance (cm):"); lcd.setCursor(0,1); lcd.print(a); delay(500); }