Sanket Joshi / Mbed 2 deprecated Lidar_UART_Airbagdeployment

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 (control motor speed)=%d cm\t",Lidar.distance());
00020        //device.printf( "%d" ,Lidar.distance());
00021          //int temp=Lidar.distance();
00022          wait_ms(100);
00023           //pc.printf("%d\n",temp);
00024          
00025          dt.reset();
00026          if(Lidar.distance()>20 and Lidar.distance()<=90)
00027          {
00028          device.printf("1"); 
00029          pc.printf("case: 1\r\n");   
00030         }
00031         
00032         else if (Lidar.distance()>90 and Lidar.distance()<=700)
00033          {
00034          device.printf("2"); 
00035          pc.printf("case: 2\r\n");   
00036         }
00037         
00038          else
00039          {
00040              device.printf("0");
00041                pc.printf("case: 0 and Airbag Deployed\r\n");  
00042              }
00043          
00044 }
00045 }