the all thing is working !
This commit is contained in:
46
vl53l0x/vl53l0x.ino
Normal file
46
vl53l0x/vl53l0x.ino
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
/* 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);
|
||||
|
||||
// wait until serial port opens for native USB devices
|
||||
while (! Serial) {
|
||||
delay(1);
|
||||
}
|
||||
|
||||
|
||||
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.println("loop");
|
||||
Serial.println(sensor.readRangeContinuousMillimeters());
|
||||
// if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }
|
||||
|
||||
// Serial.println();
|
||||
}
|
Reference in New Issue
Block a user