I expect that you know the program you posted does not compile but you do seem to know about the lcd.print() method. What's wrong with using it to print the distance on the LCD ? The one place that you don't need to put it is in setup() though. Why not put it immediately after
ut surely you want that inside loop() not setup()?
im open for criticism
Well in setup() you haven't measured the distance, have you, and even if you had it would only go once. It gets read over and over in loop(), so I'd guess that's when you want to display it. Might add a short delay just after that so the lcd doesn't go too haywire.... try without.
i change to code. i put the lcd.print (distance) in loop (as you said). now i`m thinking hot to make data show in one line and have the cm ending (47 cm, not 47)
iamponczu:
i change to code. i put the lcd.print (distance) in loop (as you said). now i`m thinking hot to make data show in one line and have the cm ending (47 cm, not 47)
else {
Serial.print(distance);
Serial.println(" cm");
lcd.setCursor(0,1);// <<<positions the cursor on the first line, at the first position
lcd.print(distance);
lcd.print(" cm");
}