check program for VL53L0X_simple library
Dependencies: VL53L0X_simple TextLCD
Please refer below page.
/users/kenjiArai/notebook/vl53l0x-tof-sensor/
Diff: main.cpp
- Revision:
- 2:f675507dcad3
- Parent:
- 1:45891160ccab
- Child:
- 3:1be17b18b200
--- a/main.cpp Mon Feb 05 22:38:59 2018 +0000 +++ b/main.cpp Tue Feb 06 10:56:44 2018 +0000 @@ -35,17 +35,17 @@ // Definition ----------------------------------------------------------------- #define USE_LCD 1 +#define USE_XSHUT 0 // Constructor ---------------------------------------------------------------- DigitalOut myled(LED1); Serial pc(USBTX, USBRX); -#if 1 //I2C i2c(P0_30, P0_7); // only for TY51822r3 I2C i2c(I2C_SDA, I2C_SCL); +#if USE_XSHUT VL53L0X sensor(i2c, D8); // XSHUT = D8 #else -//VL53L0X sensor(I2C_SDA, I2C_SCL, D8); // use XShut pin -VL53L0X sensor(I2C_SDA, I2C_SCL, NC); // XSHUT = NC +VL53L0X sensor(i2c, NC); // XSHUT = NC #endif #if USE_LCD TextLCD_I2C_N lcd(&i2c, 0x7c, TextLCD::LCD8x2); // LCD(Akizuki AQM0802A) @@ -87,7 +87,12 @@ lcd.setContrast(0x19); wait(2.0f); #endif +#if USE_XSHUT status = sensor.init_sensor(0x33); // set new I2C address +#else + // no control XSHUT then set default address (no other way) + status = sensor.init_sensor(VL53L0X_DEFAULT_ADDRESS); +#endif if (status == VL53L0X_ERROR_NONE) { pc.printf(msg0); } else {