// // hello.VL53L1x.ino // // VL53L1X hello-world // Pololu library // // Neil Gershenfeld 10/31/20 // // This work may be reproduced, modified, distributed, // performed, and displayed for any purpose, but must // acknowledge this project. Copyright is retained and // must be preserved. The work is provided as is; no // warranty is provided, and users accept all liability. // #include #include VL53L1X device; bool success = false; void setup() { // // set up serial // Serial.begin(115200); // // set up I2C // Wire1.begin(); Wire1.setClock(400000); // // set up VL53L1X // device.setTimeout(500); device.setBus(&Wire1); success = device.init(); device.setDistanceMode(VL53L1X::Long); device.setMeasurementTimingBudget(140000); device.startContinuous(140); } void loop() { // // read VL53L1X // device.read(); // // send framing // //Serial.println("hello"); // Serial.println(1); // Serial.println(2); // Serial.println(3); // Serial.println(4); // // send reading // //Serial.print(device.ranging_data.range_status); //Serial.print(" "); //Serial.print(device.ranging_data.range_mm & 255); //Serial.print(" "); //Serial.print((device.ranging_data.range_mm >> 8) & 255); //Serial.print(" "); //Serial.println(success); //to check if the device successfully works Serial.print(device.readRangeSingleMillimeters()); Serial.println(" mm"); delay(50); }