UltrasonicRanger_Example V1.0

Dependencies:   mbed RangeFinder

Revision:
2:fb4f4763a3f7
Parent:
1:285d47b768ac
Child:
3:4a2cd363c443
diff -r 285d47b768ac -r fb4f4763a3f7 main.cpp
--- a/main.cpp	Sat Aug 29 04:27:42 2015 +0000
+++ b/main.cpp	Tue Jun 18 14:46:18 2019 +0000
@@ -23,23 +23,25 @@
 
 #include "RangeFinder.h"
 
-// Seeed ultrasound range finder
-RangeFinder rf(D0, 10, 5800.0, 100000);
+// Seeed ultrasound range finder$
+// PB_3 ist Pin unten rechts
+RangeFinder rf(PB_3, 10, 5800.0, 100000);
 DigitalOut led(LED1);
 
 int main()  {
+    printf("START!\r\n");
     led = 1;
     float d;
     while (1)   {
         d = rf.read_m();
         if (d == -1.0)  {
-            printf("Timeout Error.\n");   
+            printf("Timeout Error.\r\n");   
         } else if (d > 5.0) {  
             // Seeed's sensor has a maximum range of 4m, it returns
             // something like 7m if the ultrasound pulse isn't reflected. 
-            printf("No object within detection range.\n");
+            printf("No object within detection range.\r\n");
         } else  {
-            printf("Distance = %f m.\n", d);
+            printf("Distance = %f m.\r\n", d);
         }
         wait(0.5);
         led = !led;