Dev Joshi
/
SRF02_lib
SRF02 Ultrasonic range finder library
Diff: main.cpp
- Revision:
- 0:f0cf55dd23f6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon May 02 18:44:46 2011 +0000 @@ -0,0 +1,28 @@ +#include "mbed.h" +#include "SRF02.h" + + +Serial debugport(USBTX,USBRX); +SRF02 mySensor(p9,p10,0xE0); + + + + +main() { + + time_t seconds = time(NULL); //Internal RTC + debugport.baud(115200); //set the buadrate (default is 9600 if this command is not used) + debugport.format(8,Serial::None,1); //config the serial port (default is 8N1) + debugport.printf("Hello World! %d \r\n", seconds); //send a message out of the serial port to check all is well + //include a time stamp for reference (seconds since power up) + + + while (1) { + + + debugport.printf("current distance: %.2f cm.\r\n", mySensor.distancecm()); + debugport.printf("current distance: %.2f inches.\r\n", mySensor.distancein()); + debugport.printf("current flightime: %.2f microseconds.\r\n", mySensor.distanceus()); + + } +}