Files
ESPEasy/lib/VL53L0X/examples/Continuous/Continuous.ino
T
TD-er cea567dc3d [VL53L0X] Include library description used by PIO
@tonhuisman The changes in the .h and .cpp file are yours I assume?
PIO needs the `library.properties` file to conclude it found the required library or else builds may fail.
2021-04-21 17:28:40 +02:00

38 lines
862 B
Arduino

/* This example shows how to use continuous mode to take
range measurements with the VL53L0X. It is based on
vl53l0x_ContinuousRanging_Example.c from the VL53L0X API.
The range readings are in units of mm. */
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
void setup()
{
Serial.begin(9600);
Wire.begin();
sensor.setTimeout(500);
if (!sensor.init())
{
Serial.println("Failed to detect and initialize sensor!");
while (1) {}
}
// Start continuous back-to-back mode (take readings as
// fast as possible). To use continuous timed mode
// instead, provide a desired inter-measurement period in
// ms (e.g. sensor.startContinuous(100)).
sensor.startContinuous();
}
void loop()
{
Serial.print(sensor.readRangeContinuousMillimeters());
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
Serial.println();
}