Example of LidarLite library usage. The data from sensor registers is refreshed using refreshRange() / refreshVelocity() / refreshRangeVelocity() functions and measurement data can be read into program using getRange_cm() / getVelocity_cms(). I separated the functions to refresh and report data for ease of upgrade to thread functions.

Dependencies:   LidarLite

Example of LidarLite library usage, picture below shows the setup I used to test the program.

/media/uploads/akashvibhute/lidarlitembed1768.jpg

Committer:
akashvibhute
Date:
Tue Feb 17 12:03:45 2015 +0000
Revision:
1:9c2f6fa9062f
Parent:
0:17002a5fa7bc
v0.1, 17/Feb/2015 - First version of library, tested using LPC1768 [powered via mbed 3.3v, no additional pullups on I2C necessary]

Who changed what in which revision?

UserRevisionLine numberNew contents of line
akashvibhute 0:17002a5fa7bc 1 /*
akashvibhute 0:17002a5fa7bc 2 * Example of LidarLite library usage. The data from sensor registers is refreshed using refreshRange() / refreshVelocity() / refreshRangeVelocity() functions and
akashvibhute 1:9c2f6fa9062f 3 * measurement data can be read into program using getRange_cm() / getVelocity_cms(). I separated the functions to refresh and report data for ease of upgrade to thread functions.
akashvibhute 0:17002a5fa7bc 4 *
akashvibhute 0:17002a5fa7bc 5 * Akash Vibhute < akash . roboticist [at] gmail . com >
akashvibhute 0:17002a5fa7bc 6 *
akashvibhute 0:17002a5fa7bc 7 * v0.1, 17/Feb/2015 - First version of library, tested using LPC1768 [powered via mbed 3.3v, no additional pullups on I2C necessary]
akashvibhute 0:17002a5fa7bc 8 *
akashvibhute 0:17002a5fa7bc 9 */
akashvibhute 0:17002a5fa7bc 10
akashvibhute 0:17002a5fa7bc 11 #include "LidarLite.h"
akashvibhute 0:17002a5fa7bc 12
akashvibhute 0:17002a5fa7bc 13 #define LIDARLite1_SDA p9 //SDA pin on LPC1768
akashvibhute 0:17002a5fa7bc 14 #define LIDARLite1_SCL p10 //SCL pin on LPC1768
akashvibhute 0:17002a5fa7bc 15
akashvibhute 0:17002a5fa7bc 16 LidarLite sensor1(LIDARLite1_SDA, LIDARLite1_SCL); //Define LIDAR Lite sensor 1
akashvibhute 0:17002a5fa7bc 17
akashvibhute 0:17002a5fa7bc 18 Timer dt;
akashvibhute 0:17002a5fa7bc 19
akashvibhute 0:17002a5fa7bc 20 Serial pc(USBTX,USBRX);
akashvibhute 0:17002a5fa7bc 21
akashvibhute 0:17002a5fa7bc 22 int main()
akashvibhute 0:17002a5fa7bc 23 {
akashvibhute 0:17002a5fa7bc 24 pc.baud(921600);
akashvibhute 0:17002a5fa7bc 25 dt.start();
akashvibhute 0:17002a5fa7bc 26
akashvibhute 0:17002a5fa7bc 27 while(1)
akashvibhute 0:17002a5fa7bc 28 {
akashvibhute 0:17002a5fa7bc 29 //sensor1.refreshRange();
akashvibhute 0:17002a5fa7bc 30 //sensor1.refreshVelocity();
akashvibhute 0:17002a5fa7bc 31 sensor1.refreshRangeVelocity();
akashvibhute 0:17002a5fa7bc 32
akashvibhute 0:17002a5fa7bc 33 pc.printf("range: %d cm, velocity: %d cm/s, rate: %.2f Hz\n", sensor1.getRange_cm(), sensor1.getVelocity_cms(), 1/dt.read());
akashvibhute 0:17002a5fa7bc 34 dt.reset();
akashvibhute 0:17002a5fa7bc 35 }
akashvibhute 0:17002a5fa7bc 36
akashvibhute 0:17002a5fa7bc 37 }