ghj

Dependencies:   HCSR04 TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
Mattinico
Date:
Mon Oct 24 12:54:19 2016 +0000
Parent:
2:ad0b044d0a10
Commit message:
hj

Changed in this revision

HCSR04.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HCSR04.lib	Mon Oct 24 12:54:19 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/MEM/code/HCSR04/#f14a3481cfc3
--- a/main.cpp	Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp	Mon Oct 24 12:54:19 2016 +0000
@@ -2,9 +2,30 @@
 
 #include "mbed.h"
 #include "TextLCD.h"
+#include "HCSR04.h"
 
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+TextLCD lcd(D12, D11, D5, D4, D3, D2); // rs, e, d4-d7
 
 int main() {
-    lcd.printf("Hello World!\n");
+    lcd.printf("Distance Calculator.");
+    wait(1);
+    lcd.cls();
+    lcd.locate(0,0);
+    HCSR04 sensor(D7,D8);
+    sensor.setRanges(1,150);
+    lcd.printf("Min.= %g cm", sensor.getMinRange());
+    lcd.locate(0,1);
+    lcd.printf("Max.= %g cm", sensor.getMaxRange());
+    wait(2);
+    lcd.cls();
+    lcd.locate(0,0);
+    lcd.printf("Distance: ");
+    while(1) {
+        lcd.locate(0,1);
+        lcd.printf("%5.3f cm", sensor.getDistance_cm());
+        wait_ms(1000);
+        lcd.locate(0,1);
+        lcd.printf("             ");
+    }
+        
 }
--- a/mbed.bld	Sat Dec 04 11:31:07 2010 +0000
+++ b/mbed.bld	Mon Oct 24 12:54:19 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/e2ac27c8e93e
+http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3
\ No newline at end of file