From 26b3c6f7d3ae8072c0d189f11fe81f73f763761d Mon Sep 17 00:00:00 2001
From: Aaron John Sabu <aaronjohnsabu1999@gmail.com>
Date: Mon, 4 Oct 2021 01:50:56 -0700
Subject: [PATCH] Added LIDAR Code

---
 Code/LIDAR_Code/LIDAR_Code.ino | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 Code/LIDAR_Code/LIDAR_Code.ino

diff --git a/Code/LIDAR_Code/LIDAR_Code.ino b/Code/LIDAR_Code/LIDAR_Code.ino
new file mode 100644
index 0000000..395bd93
--- /dev/null
+++ b/Code/LIDAR_Code/LIDAR_Code.ino
@@ -0,0 +1,32 @@
+/*  Wiring:
+   3v3 on ESP32 goes to VCC on CMJU-531
+   GND on ESP32 goes to GND on CMJU-531
+   D21 (GPIO21, I2C SDA) on ESP32 goes to SDA on CMJU-531
+   D22 (GPIO22, I2C SCL) on ESP32 goes to SCL on CMJU-531
+*/
+
+#include <Wire.h>
+#include <SparkFun_VL53L1X.h> // https://github.com/sparkfun/SparkFun_VL53L1X_Arduino_Library/
+
+SFEVL53L1X distanceSensor;
+int budgetIndex = 4;
+int budgetValue[7] = {15, 20, 33, 50, 100, 200, 500};
+int LED = LED_BUILTIN;
+
+void setup() {
+  Serial.begin(115200);
+  pinMode(LED, OUTPUT);
+
+  digitalWrite(LED, HIGH);
+  Wire.begin();
+  delay(250);
+  if (distanceSensor.begin() == 0)
+    Serial.println("Sensor online!");
+  distanceSensor.startRanging();
+  distanceSensor.setIntermeasurementPeriod(budgetValue[3]);
+  digitalWrite(LED, LOW);
+}
+
+void loop() {
+  Serial.println(distanceSensor.getDistance());
+}
-- 
GitLab