David Buck
/
car_dist_sens
Diff: main.cpp
- Revision:
- 0:5e45a0e565af
diff -r 000000000000 -r 5e45a0e565af main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Feb 12 12:55:58 2010 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" +#include "SRF05.h" + +DigitalOut myled(LED1); +SRF05 front (p24,p23); +Serial pc(USBTX, USBRX); + +float dist; + +int main() { + while (1) { + dist = front.read(); + if (dist < 10) { + myled =1; + } + else { + myled=0; + } + pc.printf("%.2f\n", dist); + + wait(0.5); + } + }