Ren Buggy / Mbed 2 deprecated HC-SR04_BUGGY

Dependencies:   USBDevice mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "ultrasonic_buggy.h"
00003 //#include "USBSerial.h"
00004 
00005 //USBSerial serial;
00006 
00007 
00008 int main(){
00009     
00010     float left_distance;
00011     float right_distance;
00012     stop();
00013     wait(5);
00014     //serial.printf("PROGRAM START\n\r");
00015     while(1){
00016         
00017         
00018         //wait(1);
00019         
00020         left_distance = getDistance_l();
00021         right_distance = getDistance_r();
00022         
00023         //if((left_distance > 0.3) && (right_distance > 0.3)){
00024         //serial.printf("left distance = %f   right distance = %f\n\r", left_distance, right_distance);
00025             /* if(left_distance > right_distance){
00026                 left(0.1);
00027             }
00028             else if(right_distance > left_distance){
00029                 right(0.1);
00030             }
00031         }
00032         
00033         else{
00034             right(3);
00035         }*/
00036         
00037     }
00038 }
00039