我想请问一下,将VL53L0X直接接在arduino uno R3上,这个代码就可以实现,但是我想接在一个传感器扩展板上,应该怎么改动代码啊,找了好一段时间的资料了,求求大佬们!
#include <Wire.h>
#include <VL53L0X.h>
VL53L0X sensor;
//#define LONG_RANGE
// Uncomment ONE of these two lines to get 取消注释这两行中的一行以获取
// - higher speed at the cost of lower accuracy OR 以更低的精度或更高的速度为代价
// - higher accuracy at the cost of lower speed 以较低的速度为代价获得更高的精度
sensor.setTimeout(500);
if (!sensor.init())
{
Serial.println("Failed to detect and initialize sensor!"); //无法检测和初始化传感器!
while (1) {}
}
#if defined LONG_RANGE
// lower the return signal rate limit (default is 0.25 MCPS) 降低返回信号速率限制(默认值为0.25 MCPS)
sensor.setSignalRateLimit(0.1);
// increase laser pulse periods (defaults are 14 and 10 PCLKs) 增加激光脉冲周期(默认值为14和10个脉冲周期)
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18);
sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14);
#endif
#if defined HIGH_SPEED
// reduce timing budget to 20 ms (default is about 33 ms) 将时序预算减少到20毫秒(默认值约为33毫秒)
sensor.setMeasurementTimingBudget(20000);
#elif defined HIGH_ACCURACY
// increase timing budget to 200 ms 将时序预算增加到200毫秒
sensor.setMeasurementTimingBudget(200000);
#endif
}
void loop()
{
Serial.print(sensor.readRangeSingleMillimeters());
if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); }