Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed 4DGL-uLCD-SE X_NUCLEO_53L0A1
main.cpp
00001 // Wiring Diagram: 00002 00003 // uLCD: 00004 // Mbed uLCD 00005 // Vu +5V (Vu is the 5v output pin on mbed) 00006 // p13 TX (RX on ribbon cable) 00007 // p14 RX (TX on ribbon cable) 00008 // GND GND 00009 // p30 RES 00010 00011 #include "mbed.h" 00012 #include "XNucleo53L0A1.h" //ToF 00013 #include "uLCD_4DGL.h" //lcd 00014 #include <stdio.h> 00015 Serial pc(USBTX,USBRX); 00016 DigitalOut shdn(p26); 00017 // This VL53L0X board test application performs a range measurement in polling mode 00018 // Use 3.3(Vout) for Vin, p28 for SDA, p27 for SCL, P26 for shdn on mbed LPC1768 00019 00020 //I2C sensor pins 00021 #define VL53L0_I2C_SDA p28 00022 #define VL53L0_I2C_SCL p27 00023 00024 //lcd 00025 uLCD_4DGL uLCD(p13,p14,p30); // serial tx, serial rx, reset pin; 00026 00027 static XNucleo53L0A1 *board=NULL; 00028 00029 int main() 00030 { 00031 int status; 00032 uint32_t distance; 00033 DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL); 00034 /* creates the 53L0A1 expansion board singleton obj */ 00035 board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2); 00036 shdn = 0; //must reset sensor for an mbed reset to work 00037 wait(0.1); 00038 shdn = 1; 00039 wait(0.1); 00040 /* init the 53L0A1 board with default values */ 00041 status = board->init_board(); 00042 while (status) { 00043 //pc.printf("Failed to init board! \r\n"); 00044 uLCD.printf("Failed to init board! \r\n"); 00045 status = board->init_board(); 00046 } 00047 //loop taking and printing distance 00048 while (1) { 00049 status = board->sensor_centre->get_distance(&distance); 00050 if (status == VL53L0X_ERROR_NONE) { 00051 //pc.printf("D=%ld mm\r\n", distance); 00052 uLCD.printf("D=%ld mm\r\n", distance); 00053 } 00054 } 00055 }
Generated on Wed Jul 13 2022 18:40:09 by
1.7.2