Advertisement
Guest User

vivduino1

a guest
Nov 15th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. #include <LIDARLite_v4LED.h>
  2.  
  3. /**
  4. * LIDARLite I2C Example
  5. * Author: Garmin
  6. * Modified by: Shawn Hymel (SparkFun Electronics)
  7. * Date: June 29, 2017
  8. *
  9. * Read distance from LIDAR-Lite v3 over I2C
  10. *
  11. * See the Operation Manual for wiring diagrams and more information:
  12. * http://static.garmin.com/pumac/LIDAR_Lite_v3_Operation_Manual_and_Technical_Specifications.pdf
  13. */
  14.  
  15. #include <Wire.h>
  16. #include <LIDARLite.h>
  17.  
  18. // Globals
  19. LIDARLite lidarLite;
  20. int cal_cnt = 0;
  21.  
  22. void setup()
  23. {
  24. Serial.begin(9600); // Initialize serial connection to display distance readings
  25.  
  26. lidarLite.begin(0, true); // Set configuration to default and I2C to 400 kHz
  27. lidarLite.configure(0); // Change this number to try out alternate configurations
  28. }
  29.  
  30. void loop()
  31. {
  32. int dist;
  33.  
  34. // At the beginning of every 100 readings,
  35. // take a measurement with receiver bias correction
  36. if ( cal_cnt == 0 ) {
  37. dist = lidarLite.distance(); // With bias correction
  38. } else {
  39. dist = lidarLite.distance(false); // Without bias correction
  40. }
  41.  
  42. // Increment reading counter
  43. cal_cnt++;
  44. cal_cnt = cal_cnt % 100;
  45.  
  46. // Display distance
  47. Serial.print(dist);
  48. Serial.println(" cm");
  49.  
  50. delay(10);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement