diff --git a/Code/Control/Laptop_Code/Sunday1031_Two_Lidar_Test/Sunday1031_Two_Lidar_Test.ino b/Code/Control/Laptop_Code/Sunday1031_Two_Lidar_Test/Sunday1031_Two_Lidar_Test.ino new file mode 100644 index 0000000000000000000000000000000000000000..46393d57863098bd0d8365f3bac46c49f6d69553 --- /dev/null +++ b/Code/Control/Laptop_Code/Sunday1031_Two_Lidar_Test/Sunday1031_Two_Lidar_Test.ino @@ -0,0 +1,88 @@ +#include <Wire.h> +#include <VL53L1X.h> + +#define XSHUT_pin1 A7 +#define XSHUT_pin2 A6 + + +//ADDRESS_DEFAULT 0b0101001 or 41 +#define Sensor1_newAddress 43 +#define Sensor2_newAddress 45 + + +VL53L1X Sensor1; +VL53L1X Sensor2; + + +void setup() +{ + + pinMode(XSHUT_pin1, OUTPUT); + pinMode(XSHUT_pin2, OUTPUT); + + + Serial.begin(9600); + + Wire.begin(); + Wire.setClock(100000); + + + pinMode(XSHUT_pin1, INPUT); + if (!Sensor1.init()) + { + Serial.println("Failed to detect and initialize sensor1!"); + while (1); + } + delay(10); + Sensor1.setAddress(Sensor1_newAddress); + + pinMode(XSHUT_pin2, INPUT); + if (!Sensor2.init()) + { + Serial.println("Failed to detect and initialize sensor2!"); + while (1); + } + delay(10); + Sensor2.setAddress(Sensor2_newAddress); + + + + + Sensor1.setTimeout(500); + Sensor2.setTimeout(500); + + + + Sensor1.setDistanceMode(VL53L1X::Medium); + Sensor1.setMeasurementTimingBudget(33000); + Sensor2.setDistanceMode(VL53L1X::Medium); + Sensor2.setMeasurementTimingBudget(33000); + +} + + +void loop() +{ + Sensor1.startContinuous(200); + Sensor1.read(); + Sensor1.stopContinuous(); + long time1 = millis(); + Sensor2.startContinuous(200); + Sensor2.read(); + Sensor2.stopContinuous(); + long time2 = millis(); + + + Serial.print("Sensor 1 Range: "); + Serial.print(Sensor1.ranging_data.range_mm); + Serial.print(" "); + Serial.print("Sensor 2 Range: "); + Serial.print(Sensor2.ranging_data.range_mm); + Serial.print(" "); + Serial.print(" Time between end of 1st and end of 6th messurement: "); + Serial.print(time2-time1); + + Serial.println(); + + delay(1000); +}