surya kollazhi manghat / Mbed 2 deprecated Lidar_LiteGarmin

Dependencies:   mbed LidarLitev2

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "LidarLitev2.h"
00002 
00003 
00004 LidarLitev2 Lidar(PTE25, PTE24);
00005 Serial pc(USBTX,USBRX);
00006 Serial device(PTC17, NC);
00007 
00008 Timer dt;
00009 
00010 int main()
00011 {   
00012     
00013     pc.baud(115200);
00014     device.baud(115200);
00015     Lidar.configure();
00016     dt.start();
00017 
00018     while(1){
00019          pc.printf( "distance =%d cm\t",Lidar.distance());
00020        //device.printf( "%d" ,Lidar.distance());
00021          //int temp=Lidar.distance();
00022          wait_ms(500);
00023           //pc.printf("%d\n",temp);
00024          
00025          dt.reset();
00026          if(Lidar.distance()>1 and Lidar.distance()<=30)
00027          {
00028          device.printf("1"); 
00029          pc.printf("case: 1\r\n");   
00030         }
00031         
00032         else if(Lidar.distance()>30 and Lidar.distance()<=60)
00033         {
00034          device.printf("2");  
00035            pc.printf("case: 2\r\n");  
00036          }
00037                  else if(Lidar.distance()>60 and Lidar.distance()<=90)
00038         {
00039          device.printf("3");  
00040            pc.printf("case: 3\r\n");  
00041          }
00042                  else if(Lidar.distance()>90 and Lidar.distance()<=120)
00043         {
00044          device.printf("4"); 
00045            pc.printf("case: 4\r\n");   
00046          }
00047                  else if(Lidar.distance()>120 and Lidar.distance()<=150)
00048         {
00049          device.printf("5");
00050            pc.printf("case: 5\r\n");    
00051          }
00052                  else if(Lidar.distance()>150 and Lidar.distance()<=180)
00053         {
00054          device.printf("6"); 
00055            pc.printf("case: 6\r\n");   
00056          }
00057                  else if(Lidar.distance()>180 and Lidar.distance()<=210)
00058         {
00059          device.printf("7");
00060            pc.printf("case: 7\r\n");    
00061          }
00062                  else if(Lidar.distance()>210 and Lidar.distance()<=240)
00063         {
00064          device.printf("8");  
00065            pc.printf("case: 8\r\n");  
00066          }
00067                  else if(Lidar.distance()>240 and Lidar.distance()<=800)
00068         {
00069          device.printf("9"); 
00070            pc.printf("case: 9\r\n");   
00071          }
00072          else
00073          {
00074              device.printf("0");
00075                pc.printf("case: 0\r\n");  
00076              }
00077          
00078 }
00079 }