Hello world for utilizing the Lidarlitev2 for distance measurements with the continuos reading setup

Dependencies:   LidarLitev2 mbed

Files at this revision

API Documentation at this revision

Comitter:
sventura3
Date:
Thu Oct 22 22:32:02 2015 +0000
Commit message:
comitted

Changed in this revision

LidarLitev2.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
diff -r 000000000000 -r efca88a80223 LidarLitev2.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LidarLitev2.lib	Thu Oct 22 22:32:02 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/sventura3/code/LidarLitev2/#7e6c07be1754
diff -r 000000000000 -r efca88a80223 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 22 22:32:02 2015 +0000
@@ -0,0 +1,26 @@
+#include "LidarLitev2.h"
+
+LidarLitev2 Lidar(p28, p27);// Instantiate the LidarLitev2 with name Lidar and I2C pin (SDA, SCL)
+Serial pc(USBTX,USBRX);     // Create a serial connection to pc through the mbed USB cable
+DigitalIn pinMode(p24);     // This pin is to detect the mode out of the lidar in continous mode
+
+
+Timer dt;   // Instantiate a timer for clocking the Hz of the distance reads 
+int main()
+{   
+    
+    pc.baud(115200);    // Set the baud rate for serial communication with the computer
+    Lidar.configure();  // Configure the Lidar
+    Lidar.beginContinuous();/* Set the lidar for continous reading
+                            this mode makes the lidar pull pinMode low when ready to be read*/  
+    dt.start(); // Instantiate a timer for clocking the Hz of the distance reads 
+    while(1){
+        if(!pinMode)    //Check if the lidar is pulling low
+        {
+            pc.printf("distance = %d cm frequency = %.2f Hz\n", Lidar.distanceContinuous(), 1/dt.read());
+            /*Call the lidar distance function and and the timer read while printing out
+              both statements formatted to the computer through serial. */
+        }
+
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r efca88a80223 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 22 22:32:02 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file