You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get two VL53L4CD working at the same time. I already something similar with VL6180x sensor before by using xshutdown pin, changing the adress then working from a different I2C adress. But I didn't success with this library.
Here is my code:
#include <Wire.h>
#include <SparkFun_VL53L1X.h>
#define LEFT_TOF_PIN 6
#define RIGHT_TOF_PIN 7
SFEVL53L1X tofLeft, tofRight;
uint16_t tofLeftDistance, tofRightDistance;
void setup(void) {
Wire.begin();
//----------------------------
// power off both ToF sensor
//----------------------------
digitalWrite(LEFT_TOF_PIN, LOW);
pinMode(LEFT_TOF_PIN, OUTPUT);
digitalWrite(RIGHT_TOF_PIN, LOW);
pinMode(RIGHT_TOF_PIN, OUTPUT);
//----------------------------
// power on left ToF sensor
//----------------------------
digitalWrite(LEFT_TOF_PIN, HIGH);
tofLeft.begin();
tofLeft.setI2CAddress(0x54);
tofLeft.setDistanceModeShort();
delay(100);
//----------------------------
// power on right ToF sensor
//----------------------------
digitalWrite(RIGHT_TOF_PIN, HIGH);
tofRight.begin();
tofRight.setI2CAddress(0x56);
tofRight.setDistanceModeShort();
delay(100);
//----------------------------
// start ranging both sensor
//----------------------------
tofLeft.startRanging();
tofRight.startRanging();
//----------------------------
// start serial port
//----------------------------
Serial.begin(115200);
}
void loop(void) {
if (tofLeft.checkForDataReady()) {
tofLeftDistance = tofLeft.getDistance();
tofLeft.clearInterrupt();
}
if (tofRight.checkForDataReady()) {
tofRightDistance = tofRight.getDistance();
tofRight.clearInterrupt();
}
Serial.print("Left (mm): ");
Serial.print(tofLeftDistance);
Serial.print("\tRight (mm): ");
Serial.print(tofRightDistance);
Serial.println();
delay(100);
}
The text was updated successfully, but these errors were encountered:
Hello,
I'm trying to get two VL53L4CD working at the same time. I already something similar with VL6180x sensor before by using xshutdown pin, changing the adress then working from a different I2C adress. But I didn't success with this library.
Here is my code:
The text was updated successfully, but these errors were encountered: