 /* arduino_distance
- * Uses VL53L0X Time-of-Flight Lidar sensor for distance measurement
- * Stepper motor rotation
+ * Uses VL53L0X Time-of-Flight Lidar sensor for distance measurement. Hand crafted averaging for greater precision
+ * Stepper motor rotation. In progress.
  * Work in progress - Matthew Timmons-Brown
  */
 
+// Import I2C and sensor library
 #include <Wire.h>
 #include <VL53L0X.h>
+
+// Set a constant - number of trials before averaging
 #define average_trials 3
 
+// Initialise sensor
 VL53L0X sensor;
 
+// Setup loop
 void setup()
 {
   Serial.begin(9600);

  int sum = 0;
  for (int i = 0; i < average_trials; i = i + 1)
  {
    sum += lidar_array[i];  
  }
  int result;
  result = ((float) sum) / average_trials;
  return result;
}
  
int get_distance()
{
  return sensor.readRangeSingleMillimeters();
}


{
  for (int i = 0; i < average_trials; i = i +1)
  {
    // For each index of the array, get distance and store distance at that index
    lidar_array[i] = get_distance();
  }
}
