From 007de357d3c99de34d70523dcdda8c67df06c5f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20L=C3=B8vbr=C3=B8tte=20Olsen?= Date: Thu, 14 Apr 2016 03:00:08 -0400 Subject: [PATCH] It works! --- .../Dataelektronikk/Ultrasonic Distance.ino | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 School/vg1/Dataelektronikk/Ultrasonic Distance.ino diff --git a/School/vg1/Dataelektronikk/Ultrasonic Distance.ino b/School/vg1/Dataelektronikk/Ultrasonic Distance.ino new file mode 100644 index 0000000..26f895a --- /dev/null +++ b/School/vg1/Dataelektronikk/Ultrasonic Distance.ino @@ -0,0 +1,33 @@ +#include +#include +#include + +LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); +NewPing sonar(13,12); + +void setup() +{ + lcd.begin(16,2); + + for(int i = 0; i< 3; i++) + { + lcd.backlight(); + delay(250); + lcd.noBacklight(); + delay(250); + } + + lcd.backlight(); + + lcd.setCursor(0,0); + lcd.print("Distance in cm"); +} + +void loop() +{ + lcd.setCursor(0,1); + lcd.print(" "); + lcd.setCursor(0,1); + lcd.print(sonar.ping_cm()); + delay(50); +}