Exercise VL53L0X

Dependencies:   VL53L0X mbed

Files at this revision

API Documentation at this revision

Comitter:
highroads
Date:
Sun Feb 26 12:45:58 2017 +0000
Child:
1:3588081d929a
Commit message:
First version

Changed in this revision

VL53L0X.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/VL53L0X.lib	Sun Feb 26 12:45:58 2017 +0000
@@ -0,0 +1,1 @@
+VL53L0X#aae0c331fe7e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 26 12:45:58 2017 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "VL53L0X.h"
+
+/* This example shows how to use continuous mode to take
+range measurements with the VL53L0X. It is based on
+vl53l0x_ContinuousRanging_Example.c from the VL53L0X API.
+The range readings are in units of mm. */
+
+
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+DigitalInOut sda_D(PB_9);
+DigitalInOut scl_D(PB_8);
+
+// mbed uses 8bit addresses shift address by 1 bit left
+VL53L0X sensor_D(PB_9, PB_8);
+
+
+int main() {
+ pc.baud(115200);
+
+  wait_ms(100); // delay .1s
+    pc.printf("starting continuous\n");
+  sda_D.mode(PullUp);
+  scl_D.mode(PullUp);
+  //sensor_D.getIdentification(&identification); // Retrieve manufacture info from device memory
+  //printIdentification(&identification); // Helper function to print all the Module information
+
+  sensor_D.init();
+  sensor_D.setTimeout(500);
+
+  // Start continuous back-to-back mode (take readings as
+  // fast as possible).  To use continuous timed mode
+  // instead, provide a desired inter-measurement period in
+  // ms (e.g. sensor.startContinuous(100)).
+  sensor_D.startContinuous(50);
+  while(1) {
+    pc.printf("range  = %d\n",sensor_D.readRangeContinuousMillimeters());
+//    if (sensor_D.timeoutOccurred()) { printf(" TIMEOUT\n"); }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Feb 26 12:45:58 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f
\ No newline at end of file