#include unsigned long T = 0; unsigned long L = 0; byte pi[8] = { 0b11111, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b10001, 0b00000,}; byte S[8] = { 0b11111, 0b01000, 0b00100, 0b00010, 0b00100, 0b01000, 0b11111, 0b00000,}; LiquidCrystal lcd(7,6,5,4,3,2); void setup() { lcd.begin(16,2); lcd.createChar(0,pi); lcd.createChar(1,S); pinMode (11, INPUT); pinMode(10, OUTPUT); } void loop() { digitalWrite(10, HIGH); delayMicroseconds(50); digitalWrite(10, LOW); T = pulseIn(11, HIGH); L = (T*340)/2; L=L/10000; lcd.setCursor(3,0); lcd.print("A"); lcd.write(byte(0)); lcd.print("O"); lcd.write(byte(1)); lcd.print("T"); lcd.print("A"); lcd.write(byte(1)); lcd.print("H"); lcd.print(":"); lcd.setCursor(4,1); if (L<10){ lcd.print(" "); lcd.print(" "); lcd.print(L);} else if (L<100){ lcd.print(" "); lcd.print(L);} else if (L<1000){ lcd.print(L);} lcd.print(" cm"); delay(10); }