From d92c0c0130acf4467f30d00151f04f78a49e8f22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Thu, 14 Apr 2016 03:32:36 -0400 Subject: [PATCH] Update with leading zeroes, instead of clearing --- School/vg1/Dataelektronikk/Ultrasonic Distance.ino | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/School/vg1/Dataelektronikk/Ultrasonic Distance.ino b/School/vg1/Dataelektronikk/Ultrasonic Distance.ino index ea302f9..43d022f 100644 --- a/School/vg1/Dataelektronikk/Ultrasonic Distance.ino +++ b/School/vg1/Dataelektronikk/Ultrasonic Distance.ino @@ -23,11 +23,13 @@ void setup() lcd.print("Distance in cm"); } + + void loop() { lcd.setCursor(0,1); - lcd.print(" "); - lcd.setCursor(0,1); - lcd.print(sonar.ping_cm()); + char cm[3]; + sprintf(cm, "%.3i", sonar.ping_cm()); + lcd.print(cm); delay(50); }