Hello world for utilizing the Lidarlitev2 for distance measurements with the continuos reading setup
Dependencies: LidarLitev2 mbed
main.cpp
- Committer:
- sventura3
- Date:
- 2015-10-22
- Revision:
- 0:efca88a80223
File content as of revision 0:efca88a80223:
#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. */ } } }