Cooper Liu
/
Sonar_Robot
Diff: main.cpp
- Revision:
- 0:9352a72a9d85
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Mar 14 17:05:44 2012 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "RFSRF05.h" + +DigitalOut Led_1(LED1); +DigitalOut Led_2(LED2); + +RFSRF05 my_srf(p13,p21,p22,p23,p24,p25,p26,p5,p6,p7,p8,p9); + +Serial pc(USBTX, USBRX); // tx, rx + +float Distance[3],Distance_Shortest,Distance_Largest; +volatile char SendByte; + +int main() { + pc.printf("Robot Side Side \n"); + while (1) { + Led_2 = 1; + wait_ms(100); + Distance[0] = my_srf.read0(); + Distance[1] = my_srf.read1(); + Distance[2] = my_srf.read2(); + pc.printf("%.1f, %.1f, %.1f \n",Distance[0],Distance[1],Distance[2]); +// pc.printf("Distance0 = %.1f\n",Distance[0]); +// pc.printf("Distance1 = %.1f\n",Distance[1]); +// pc.printf("Distance2 = %.1f\n",Distance[2]); +// pc.printf("\n\r"); + Led_2 = 0; + wait_ms(50); + + + + } +}