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: X_NUCLEO_53L0A1 mbed
Fork of HelloWorld_53L0A1 by
main.cpp
00001 #include "mbed.h" 00002 #include "XNucleo53L0A1.h" 00003 #include <stdio.h> 00004 00005 #define VL53L0_I2C_SDA D4 00006 #define VL53L0_I2C_SCL D5 00007 00008 static XNucleo53L0A1 *board=NULL; 00009 DigitalOut dout(D8); 00010 DigitalOut Led(D13); 00011 int count = 0; 00012 00013 00014 int main(){ 00015 int status; 00016 uint32_t distance = 0; 00017 00018 DevI2C *device_i2c = new DevI2C(VL53L0_I2C_SDA, VL53L0_I2C_SCL); 00019 00020 board = XNucleo53L0A1::instance(device_i2c, A2, D8, D2); 00021 status = board->init_board(); 00022 if (status) { 00023 return 0; 00024 } 00025 dout = 0.0; 00026 Led = 0.0; 00027 while (1) { 00028 status = board->sensor_centre->get_distance(&distance); 00029 if (status == VL53L0X_ERROR_NONE) { 00030 if(distance <= 100){ 00031 count++; 00032 }else{ 00033 count--; 00034 } 00035 }else{ 00036 count--; 00037 } 00038 if(count >= 20){ 00039 count = 20; 00040 }else if(count <= -10){ 00041 count = -10; 00042 } 00043 if(count >= 10){ 00044 dout = 1.0; 00045 Led = 1.0; 00046 }else if(count <= 0){ 00047 dout = 0.0; 00048 Led = 0.0; 00049 } 00050 } 00051 }
Generated on Fri Jul 15 2022 06:16:29 by
1.7.2
