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.
Fork of HelloWorld_53L0A1 by
main.cpp
00001 #include "mbed.h" 00002 #include "x_nucleo_53l0a1.h" 00003 #include <stdio.h> 00004 00005 #define VL53L0_I2C_SDA D4 00006 #define VL53L0_I2C_SCL D5 00007 00008 static X_NUCLEO_53L0A1 *board=NULL; 00009 Serial pc(USBTX, USBRX); 00010 Serial pc2(D1,D0); 00011 00012 00013 DigitalOut myled(LED1); 00014 00015 00016 int main() 00017 { 00018 int status,i,add,ds[12]; 00019 uint32_t distance; 00020 pc.baud(115200); 00021 pc2.baud(115200); 00022 00023 DevI2C *device_i2c =new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL); 00024 00025 board=X_NUCLEO_53L0A1::Instance(device_i2c, A2, D8, D2); 00026 00027 status=board->InitBoard(); 00028 00029 for(i = 0; i <= 10; i++) { 00030 ds[i] = 0; 00031 } 00032 myled = 1; 00033 while(1) 00034 { 00035 for(i = 0; i <= 2; i++) { 00036 ds[i] = ds [i+1]; 00037 } 00038 status = board->sensor_centre->GetDistance(&distance); 00039 ds[2] = distance; 00040 if(ds[2] == 0){ 00041 ds[2] = ds[1]; 00042 } 00043 for(i = 0; i <= 2; i++) { 00044 add = ds[i] + add; 00045 } 00046 add = add/30; 00047 00048 pc.printf("pc%03d\r\n", add); 00049 pc2.printf("a%03d", add); 00050 00051 00052 if(add > 4) 00053 { 00054 myled = 1; 00055 } 00056 else 00057 { 00058 myled = 0; 00059 } 00060 } 00061 00062 } 00063
Generated on Wed Jul 27 2022 10:47:12 by
1.7.2
