Dependencies:   mbed RFSRF05

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "RFSRF05.h"
00003 
00004 DigitalOut Led_1(LED1);
00005 DigitalOut Led_2(LED2);
00006 
00007 RFSRF05 my_srf(p13,p21,p22,p23,p24,p25,p26,p5,p6,p7,p8,p9);
00008 
00009 Serial pc(USBTX, USBRX); // tx, rx
00010 
00011 float Distance[3],Distance_Shortest,Distance_Largest;
00012 volatile char SendByte;
00013 
00014 int main() {
00015     pc.printf("Robot Side Side \n");
00016     while (1) {
00017         Led_2 = 1;
00018         wait_ms(100);
00019         Distance[0] = my_srf.read0();
00020         Distance[1] = my_srf.read1();
00021         Distance[2] = my_srf.read2();
00022         pc.printf("%.1f, %.1f, %.1f \n",Distance[0],Distance[1],Distance[2]);
00023 //        pc.printf("Distance0 = %.1f\n",Distance[0]);
00024 //        pc.printf("Distance1 = %.1f\n",Distance[1]);
00025 //        pc.printf("Distance2 = %.1f\n",Distance[2]);
00026 //        pc.printf("\n\r");
00027         Led_2 = 0;
00028         wait_ms(50);
00029 
00030 
00031 
00032     }
00033 }