/* 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 #include #include VL53L0X sensor; const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; LiquidCrystal lcd(rs, en, d4, d5, d6, d7); void setup() { Serial.begin(9600); Wire.begin(); lcd.begin(16, 2); // Print a message to the LCD. lcd.print("hello, world!"); sensor.init(); sensor.setTimeout(500); // 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(100); } void loop() { Serial.print(sensor.readRangeContinuousMillimeters()); if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } Serial.println(); lcd.setCursor(0, 1); // print the number of seconds since reset: lcd.print(sensor.readRangeContinuousMillimeters()); if (sensor.timeoutOccurred()) { lcd.print(" TIMEOUT"); } delay(10); lcd.clear(); }