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 LidarLitev2
main.cpp
00001 #include "LidarLitev2.h" 00002 00003 00004 LidarLitev2 Lidar(PTE25, PTE24); 00005 Serial pc(USBTX,USBRX); //UART0 00006 Serial device(PTC17, PTC16); //UART3 00007 Serial kw41z(PTD3, PTD2); //UART2 00008 00009 int counter = 0; 00010 00011 Timer dt; 00012 00013 int main() 00014 { 00015 00016 pc.baud(115200); 00017 device.baud(115200); 00018 kw41z.baud(115200); 00019 Lidar.configure(); 00020 dt.start(); 00021 00022 while(1){ 00023 pc.printf( "distance =%d cm\t",Lidar.distance()); 00024 //device.printf( "%d" ,Lidar.distance()); 00025 //int temp=Lidar.distance(); 00026 wait_ms(500); 00027 //pc.printf("%d\n",temp); 00028 00029 dt.reset(); 00030 if(Lidar.distance()>1 and Lidar.distance()<=15) 00031 { 00032 device.printf("1"); 00033 //kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r255 g0 b0\n"); 00034 pc.printf("case: 1\r\n"); 00035 if (counter == 0){ 00036 kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r255 g0 b0\n"); 00037 counter = 1; 00038 } 00039 } 00040 00041 else if(Lidar.distance()>15 and Lidar.distance()<=60) 00042 { 00043 device.printf("2"); 00044 pc.printf("case: 2\r\n"); 00045 if (counter == 0){ 00046 kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r255 g0 b0\n"); 00047 counter = 1; 00048 } 00049 } 00050 else if(Lidar.distance()>60 and Lidar.distance()<=120) 00051 { 00052 device.printf("3"); 00053 //kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00054 pc.printf("case: 3\r\n"); 00055 if (counter == 1) { 00056 kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00057 counter = 0; 00058 } 00059 } 00060 else if(Lidar.distance()>120 and Lidar.distance()<=180) 00061 { 00062 device.printf("4"); 00063 //kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00064 pc.printf("case: 4\r\n"); 00065 if (counter == 1) { 00066 kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00067 counter = 0; 00068 } 00069 } 00070 else if(Lidar.distance()>180) 00071 { 00072 device.printf("5"); 00073 //kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00074 pc.printf("case: 5\r\n"); 00075 if (counter == 1) { 00076 kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00077 counter = 0; 00078 } 00079 } 00080 else 00081 { 00082 device.printf("0"); 00083 //kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r0 g255 b0\n"); 00084 pc.printf("case: 0\r\n"); 00085 if (counter == 0) { 00086 kw41z.printf("coap CON POST fd18:16b7:2982:2c23:d07c:a5c0:a751:5e10 /led rgb r255 g0 b0\n"); 00087 counter = 1; 00088 } 00089 } 00090 00091 } 00092 }
Generated on Fri Dec 9 2022 17:01:02 by
1.7.2