Working multi-sensor TOF setup

Dependencies:   mbed VL53L0X

Revision:
2:8758d2437277
Parent:
1:05a851d3ac3b
Child:
3:5edb525fae6d
--- a/main.cpp	Tue Feb 26 18:12:34 2019 +0000
+++ b/main.cpp	Tue Feb 26 19:58:08 2019 +0000
@@ -10,6 +10,8 @@
  
 Serial pc(USBTX, USBRX);
 static DevI2C devI2c(VL53L0_I2C_SDA, VL53L0_I2C_SCL); 
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
  
 int main()
 {   
@@ -27,21 +29,30 @@
     uint32_t distance2;
     int status1;
     int status2;
+  
     while(1){
         status1 = range1.get_distance(&distance1);
+        status2 = range2.get_distance(&distance2);
         if (status1 == VL53L0X_ERROR_NONE) {
-            printf("Range1 [mm]:            %6ld\r\n", distance1);
+//            printf("Range1 [mm]:            %6ld\r\n", distance1);
+            if (distance1 > 0) {
+                led1 = 0;
+            }
+            else {
+                led1 = 1;
+            }
         } else {
-            printf("Range1 [mm]:                --\r\n");
+//            printf("Range1 [mm]:                --\r\n");
+            led1 = 1;
         }
-
-        status2 = range2.get_distance(&distance2);
         if (status2 == VL53L0X_ERROR_NONE) {
-            printf("Range2 [mm]:            %6ld\r\n", distance2);
+//            printf("Range2 [mm]:            %6ld\r\n", distance2);
+            led2 = 0;
         } else {
-            printf("Range2 [mm]:                --\r\n");
+//            printf("Range2 [mm]:                --\r\n");
+            led2 = 1;
         }
-        wait(0.5);                 
+        wait(0.1);                 
     }
  
 }