This is a library that makes VL53L0X easy to handle.
# Example
include the mbed library with this snippet
#include "mbed.h"
#include "TI_VL53L0X.h"
DigitalOut led1(LED1);
DigitalIn button(p11);
TI_VL53L0X vl53l0x;
int main() {
led1 = 0;
vl53l0x.setup();
vl53l0x.calibration();
while (true) {
if (led1) {
int averageRange = vl53l0x.getMeasurement();
if (9999 != averageRange) {
printf("VL53L0X measurement average %d\n", averageRange);
if (averageRange > 300) {
led1 = 0;
} else {
led1 = 1;
}
}
}
if (button) {
printf("Button Pressed\n\r");
wait(0.7);
led1 = !led1;
if (led1) {
vl53l0x.startMeasurement();
} else {
vl53l0x.stopMeasurement();
}
}
}
}
takuya ichise